power_assert 0.2.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40425b849bc13c3697522de357afa6176914bddc
4
- data.tar.gz: fae40e27a12725faf59a05af5e3e9105a3d2a429
3
+ metadata.gz: ca399789200505cc381792aa1953ff3080e0263d
4
+ data.tar.gz: 0ca2eca0a18cf8730baca78482d8bcb423477ec1
5
5
  SHA512:
6
- metadata.gz: 338d87fbfb75835d6473fc244244929bf624fa55cc27df94e6e46fc5fee58843663d3b4ef9617836b0636d6c7bdc765d6270a2d4b30efb5350029154d148b877
7
- data.tar.gz: 34c1313f33f65a78cd08177c236b16e33c5780aa1e5d9ede4f4cfff49b27ddfc3cdb0acda1575b16969f9e421908dabcc6f0a12491ff0879b9fb6a98d679aded
6
+ metadata.gz: 4166d468bc99599f1dfd6318276a70d7014bed4e275b6172f52883bf1ad1bbe20986d692688618b482a42b52f8ac085ee12eb9246be7b777577a3652e2fb17dd
7
+ data.tar.gz: 3625046283d993627f849bf3a78c6b5a1d502a9621382aa761202583643688c865a12d05d7c964ab819dc425db50747a15c6f4adb47b4ae4aea4e42351bcd39c
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1
5
- - 2.2
6
- - 2.3.0
3
+ - 2.0.0-p648
4
+ - 2.1.10
5
+ - 2.2.5
6
+ - 2.3.1
7
7
  - ruby-head
8
8
  matrix:
9
9
  allow_failures:
data/BSDL CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2014-2015 Kazuki Tsujimoto, All rights reserved.
1
+ Copyright (C) 2014-2016 Kazuki Tsujimoto, All rights reserved.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2014-2015 Kazuki Tsujimoto, All rights reserved.
1
+ Copyright (C) 2014-2016 Kazuki Tsujimoto, All rights reserved.
2
2
 
3
3
  You can redistribute it and/or modify it under either the terms of the
4
4
  2-clause BSDL (see the file BSDL), or the conditions below:
data/Rakefile CHANGED
@@ -7,3 +7,10 @@ Rake::TestTask.new do |t|
7
7
  t.ruby_opts = ["-w", "-r./test/helper"]
8
8
  t.test_files = FileList["test/test_*.rb"]
9
9
  end
10
+
11
+ desc "Run the benchmark suite"
12
+ task('benchmark') do
13
+ Dir.glob('benchmarks/bm_*.rb').each do |f|
14
+ load(f)
15
+ end
16
+ end
@@ -0,0 +1,59 @@
1
+ # Yhpg
2
+ # https://gist.github.com/yancya/37d79e02a91afcfdeed1
3
+ #
4
+ # Auhtor: yancya
5
+
6
+ require_relative 'helper'
7
+
8
+ class Yhpg
9
+ MAPPING = [*'0'..'9', *'A'..'Z', *'a'..'z']
10
+
11
+ def initialize(data)
12
+ @n, @list = data.split(":").tap { |n, list| break [n.to_i, list.split(",").map { |str| Yhpg.decode(str) }] }
13
+ x_nominee = @list.map { |x, _| x }.map { |x| [x, x + 1] }.flatten.tap { |a| a.push(*[0, 62])}.uniq
14
+ y_nominee = @list.map { |_, y| y }.map { |y| [y, y + 1] }.flatten.tap { |a| a.push(*[0, 62])}.uniq
15
+ x_range_patterns = x_nominee.combination(2).map { |a| (a.min..a.max) }
16
+ y_range_patterns = y_nominee.combination(2).map { |a| (a.min..a.max) }
17
+ squares = x_range_patterns.product(y_range_patterns)
18
+ targets = squares.select { |xrange, yrange| @list.select { |p| check(xrange, yrange, p) }.size == @n }
19
+ @areas = targets.map { |x, y| [(x.max - x.min) * (y.max - y.min), x, y] }
20
+ end
21
+
22
+ def debug
23
+ p [@areas.min_by(&:first), @areas.max_by(&:first)]
24
+ end
25
+
26
+ def Yhpg.decode(str)
27
+ str.chars.map { |w| MAPPING.index(w) }
28
+ end
29
+
30
+ def check(xrange, yrange, target)
31
+ x, y = target
32
+ (xrange.include?(x) && xrange.include?(x + 1)) &&
33
+ (yrange.include?(y) && yrange.include?(y + 1))
34
+ end
35
+
36
+ def output
37
+ case res = [@areas.map(&:first).min, @areas.map(&:first).max].join(',')
38
+ when ','
39
+ '-'
40
+ else
41
+ res
42
+ end
43
+ end
44
+ end
45
+
46
+ [
47
+ ["4:00,11,zz,yy,1y,y1", "3600,3721"], # /*05*/
48
+ ].each do |(actual, expect)|
49
+ Benchmark.bm(30) do |x|
50
+ x.report("expr") { Yhpg.new(actual).output == expect }
51
+ x.report("TracePoint.trace { expr }") { TracePoint.new(:return, :c_return) {}.enable { Yhpg.new(actual).output == expect } }
52
+ x.report("assertion_message { expr }") {
53
+ assertion_message { Yhpg.new(actual).output == expect }
54
+ }
55
+ x.report("assertion_message { !expr }") {
56
+ assertion_message { not Yhpg.new(actual).output == expect }
57
+ }
58
+ end
59
+ end
@@ -0,0 +1,8 @@
1
+ require 'benchmark'
2
+ require 'power_assert'
3
+
4
+ def assertion_message(source = nil, source_binding = TOPLEVEL_BINDING, &blk)
5
+ ::PowerAssert.start(source || blk, assertion_method: __callee__, source_binding: source_binding) do |pa|
6
+ pa.message unless pa.yield
7
+ end
8
+ end
@@ -1,6 +1,6 @@
1
1
  # power_assert.rb
2
2
  #
3
- # Copyright (C) 2014-2015 Kazuki Tsujimoto, All rights reserved.
3
+ # Copyright (C) 2014-2016 Kazuki Tsujimoto, All rights reserved.
4
4
 
5
5
  begin
6
6
  captured = false
@@ -22,7 +22,7 @@ require 'ripper'
22
22
  module PowerAssert
23
23
  class << self
24
24
  def configuration
25
- @configuration ||= Configuration[false]
25
+ @configuration ||= Configuration[false, false]
26
26
  end
27
27
 
28
28
  def configure
@@ -45,7 +45,7 @@ module PowerAssert
45
45
  end
46
46
  end
47
47
 
48
- Configuration = Struct.new(:lazy_inspection)
48
+ Configuration = Struct.new(:lazy_inspection, :_trace_alias_method)
49
49
  private_constant :Configuration
50
50
 
51
51
  module Empty
@@ -90,7 +90,7 @@ module PowerAssert
90
90
  Ident = Struct.new(:type, :name, :column)
91
91
 
92
92
  TARGET_CALLER_DIFF = {return: 5, c_return: 4}
93
- TARGET_INDEX_OFFSET = {bmethod: 3, method: 2}
93
+ TARGET_INDEX_OFFSET = 2
94
94
 
95
95
  attr_reader :message_proc
96
96
 
@@ -111,40 +111,54 @@ module PowerAssert
111
111
  @base_caller_length = -1
112
112
  @assertion_method_name = assertion_method.to_s
113
113
  @message_proc = -> {
114
- return nil if @base_caller_length < 0
114
+ raise RuntimeError, 'call #yield at first' if @base_caller_length < 0
115
115
  @message ||= build_assertion_message(@line || '', methods || [], return_values, refs || [], @assertion_proc.binding).freeze
116
116
  }
117
117
  @proc_local_variables = @assertion_proc.binding.eval('local_variables').map(&:to_s)
118
118
  target_thread = Thread.current
119
+ @trace_call = TracePoint.new(:call, :c_call) do |tp|
120
+ next if @base_caller_length < 0
121
+ locs = caller_locations
122
+ if locs.length >= @base_caller_length+TARGET_INDEX_OFFSET and Thread.current == target_thread
123
+ idx = -(@base_caller_length+TARGET_INDEX_OFFSET)
124
+ path = locs[idx].path
125
+ lineno = locs[idx].lineno
126
+ @line ||= open(path).each_line.drop(lineno - 1).first
127
+ idents = extract_idents(Ripper.sexp(@line))
128
+ methods, refs = idents.partition {|i| i.type == :method }
129
+ method_ids = methods.map(&:name).map(&:to_sym).each_with_object({}) {|i, h| h[i] = true }
130
+ @trace_call.disable
131
+ end
132
+ end
133
+ trace_alias_method = PowerAssert.configuration._trace_alias_method
119
134
  @trace = TracePoint.new(:return, :c_return) do |tp|
120
- next if method_ids and ! method_ids.include?(tp.method_id)
135
+ method_id = (trace_alias_method &&
136
+ tp.event == :return &&
137
+ tp.binding.eval('::Kernel.__callee__')) || tp.method_id
138
+ next if method_ids and ! method_ids[method_id]
121
139
  next unless tp.binding # workaround for ruby 2.2
140
+ if tp.event == :c_return
141
+ loc = tp.binding.eval('[__LINE__, __FILE__]')
142
+ next unless lineno == loc[0] and path == loc[1]
143
+ end
122
144
  locs = tp.binding.eval('::Kernel.caller_locations')
123
145
  current_diff = locs.length - @base_caller_length
124
- target_diff = TARGET_CALLER_DIFF[tp.event]
125
- is_target_bmethod = current_diff < target_diff
126
- if (is_target_bmethod or current_diff == target_diff) and Thread.current == target_thread
127
- idx = target_diff - TARGET_INDEX_OFFSET[is_target_bmethod ? :bmethod : :method]
128
- unless path
129
- path = locs[idx].path
130
- lineno = locs[idx].lineno
131
- @line ||= open(path).each_line.drop(lineno - 1).first
132
- idents = extract_idents(Ripper.sexp(@line))
133
- methods, refs = idents.partition {|i| i.type == :method }
134
- method_ids = methods.map(&:name).map(&:to_sym).uniq
135
- end
146
+ if current_diff <= TARGET_CALLER_DIFF[tp.event] and Thread.current == target_thread
147
+ idx = -(@base_caller_length+TARGET_INDEX_OFFSET)
136
148
  if path == locs[idx].path and lineno == locs[idx].lineno
137
149
  val = PowerAssert.configuration.lazy_inspection ?
138
150
  tp.return_value :
139
151
  InspectedValue.new(SafeInspectable.new(tp.return_value).inspect)
140
- return_values << Value[tp.method_id.to_s, val, nil]
152
+ return_values << Value[method_id.to_s, val, nil]
141
153
  end
142
154
  end
143
155
  end
144
156
  end
145
157
 
146
158
  def yield
147
- do_yield(&@assertion_proc)
159
+ @trace_call.enable do
160
+ do_yield(&@assertion_proc)
161
+ end
148
162
  end
149
163
 
150
164
  def message
@@ -1,3 +1,3 @@
1
1
  module PowerAssert
2
- VERSION = "0.2.7"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -4,6 +4,13 @@ require 'ripper'
4
4
  require 'set'
5
5
 
6
6
  class TestPowerAssert < Test::Unit::TestCase
7
+ class << self
8
+ def t(msg='', &blk)
9
+ loc = caller_locations(1, 1)[0]
10
+ test("#{loc.path} --location #{loc.lineno} #{msg}", &blk)
11
+ end
12
+ end
13
+
7
14
  EXTRACT_METHODS_TEST = [
8
15
  [[[:method, "c", 4], [:method, "b", 2], [:method, "d", 8], [:method, "a", 0]],
9
16
  'a(b(c), d)'],
@@ -148,194 +155,215 @@ class TestPowerAssert < Test::Unit::TestCase
148
155
  false
149
156
  end
150
157
 
151
- def test_lazy_inspection
152
- PowerAssert.configure do |c|
153
- assert !c.lazy_inspection
154
- end
155
- assert_equal <<END.chomp, assertion_message {
156
- 'a'.sub(/./, 'b').sub!(/./, 'c')
157
- | |
158
- | "c"
159
- "b"
160
- END
161
- 'a'.sub(/./, 'b').sub!(/./, 'c')
162
- }
163
-
164
- PowerAssert.configure do |c|
165
- c.lazy_inspection = true
166
- end
167
- begin
158
+ sub_test_case 'lazy_inspection' do
159
+ t do
160
+ PowerAssert.configure do |c|
161
+ assert !c.lazy_inspection
162
+ end
168
163
  assert_equal <<END.chomp, assertion_message {
169
164
  'a'.sub(/./, 'b').sub!(/./, 'c')
170
165
  | |
171
166
  | "c"
172
- "c"
167
+ "b"
173
168
  END
174
169
  'a'.sub(/./, 'b').sub!(/./, 'c')
175
170
  }
176
- ensure
171
+ end
172
+
173
+ t do
177
174
  PowerAssert.configure do |c|
178
- c.lazy_inspection = false
175
+ c.lazy_inspection = true
176
+ end
177
+ begin
178
+ assert_equal <<END.chomp, assertion_message {
179
+ 'a'.sub(/./, 'b').sub!(/./, 'c')
180
+ | |
181
+ | "c"
182
+ "c"
183
+ END
184
+ 'a'.sub(/./, 'b').sub!(/./, 'c')
185
+ }
186
+ ensure
187
+ PowerAssert.configure do |c|
188
+ c.lazy_inspection = false
189
+ end
179
190
  end
180
191
  end
181
192
  end
182
193
 
183
- def test_assertion_message
184
- a = 0
185
- @b = 1
186
- @@c = 2
187
- $d = 3
188
- assert_equal <<END.chomp, assertion_message {
189
- String(a) + String(@b) + String(@@c) + String($d)
190
- | | | | | | | | | | |
191
- | | | | | | | | | | 3
192
- | | | | | | | | | "3"
193
- | | | | | | | | "0123"
194
- | | | | | | | 2
195
- | | | | | | "2"
196
- | | | | | "012"
197
- | | | | 1
198
- | | | "1"
199
- | | "01"
200
- | 0
201
- "0"
202
- END
203
- String(a) + String(@b) + String(@@c) + String($d)
204
- }
205
-
206
-
207
- assert_equal <<END.chomp, assertion_message {
208
- "0".class == "3".to_i.times.map {|i| i + 1 }.class
209
- | | | | | |
210
- | | | | | Array
211
- | | | | [1, 2, 3]
212
- | | | #<Enumerator: 3:times>
213
- | | 3
214
- | false
215
- String
194
+ sub_test_case 'assertion_message' do
195
+ t do
196
+ a = 0
197
+ @b = 1
198
+ @@c = 2
199
+ $d = 3
200
+ assert_equal <<END.chomp, assertion_message {
201
+ String(a) + String(@b) + String(@@c) + String($d)
202
+ | | | | | | | | | | |
203
+ | | | | | | | | | | 3
204
+ | | | | | | | | | "3"
205
+ | | | | | | | | "0123"
206
+ | | | | | | | 2
207
+ | | | | | | "2"
208
+ | | | | | "012"
209
+ | | | | 1
210
+ | | | "1"
211
+ | | "01"
212
+ | 0
213
+ "0"
216
214
  END
217
- "0".class == "3".to_i.times.map {|i| i + 1 }.class
218
- }
219
-
220
-
221
- assert_equal '', assertion_message {
222
- false
223
- }
224
-
215
+ String(a) + String(@b) + String(@@c) + String($d)
216
+ }
217
+ end
225
218
 
226
- assert_equal <<END.chomp,
227
- assertion_message { "0".class }
228
- |
229
- String
219
+ t do
220
+ assert_equal <<END.chomp, assertion_message {
221
+ "0".class == "3".to_i.times.map {|i| i + 1 }.class
222
+ | | | | | |
223
+ | | | | | Array
224
+ | | | | [1, 2, 3]
225
+ | | | #<Enumerator: 3:times>
226
+ | | 3
227
+ | false
228
+ String
230
229
  END
231
- assertion_message { "0".class }
230
+ "0".class == "3".to_i.times.map {|i| i + 1 }.class
231
+ }
232
+ end
232
233
 
234
+ t do
235
+ assert_equal '', assertion_message {
236
+ false
237
+ }
238
+ end
233
239
 
234
- assert_equal <<END.chomp,
235
- "0".class
236
- |
237
- String
240
+ t do
241
+ assert_equal <<END.chomp,
242
+ assertion_message { "0".class }
243
+ |
244
+ String
238
245
  END
239
- Assertion {
240
- "0".class
241
- }
242
-
246
+ assertion_message { "0".class }
247
+ end
243
248
 
244
- assert_equal <<END.chomp,
245
- Assertion { "0".class }
246
- |
247
- String
249
+ t do
250
+ assert_equal <<END.chomp,
251
+ "0".class
252
+ |
253
+ String
248
254
  END
249
- Assertion { "0".class }
250
-
255
+ Assertion {
256
+ "0".class
257
+ }
258
+ end
251
259
 
252
- assert_equal <<END.chomp, assertion_message {
253
- Set.new == Set.new([0])
254
- | | | | |
255
- | | | | #<Set: {0}>
256
- | | | Set
257
- | | false
258
- | #<Set: {}>
259
- Set
260
+ t do
261
+ assert_equal <<END.chomp,
262
+ Assertion { "0".class }
263
+ |
264
+ String
260
265
  END
261
- Set.new == Set.new([0])
262
- }
263
-
266
+ Assertion { "0".class }
267
+ end
264
268
 
265
- var = [10,20]
266
- assert_equal <<END.chomp, assertion_message {
267
- var[0] == 0
268
- | | |
269
- | | false
270
- | 10
271
- [10, 20]
272
- END
273
- var[0] == 0
274
- }
275
-
276
- a = 1
277
- assert_equal <<END.chomp, assertion_message {
278
- ! a != (+a == -a)
279
- | | | || | ||
280
- | | | || | |1
281
- | | | || | -1
282
- | | | || false
283
- | | | |1
284
- | | | 1
285
- | | false
286
- | 1
287
- false
269
+ t do
270
+ assert_equal <<END.chomp, assertion_message {
271
+ Set.new == Set.new([0])
272
+ | | | | |
273
+ | | | | #<Set: {0}>
274
+ | | | Set
275
+ | | false
276
+ | #<Set: {}>
277
+ Set
288
278
  END
289
- ! a != (+a == -a)
290
- }
279
+ Set.new == Set.new([0])
280
+ }
281
+ end
291
282
 
292
- assert_equal <<END.chomp, assertion_message {
293
- bmethod
294
- |
295
- false
283
+ t do
284
+ var = [10,20]
285
+ assert_equal <<END.chomp, assertion_message {
286
+ var[0] == 0
287
+ | | |
288
+ | | false
289
+ | 10
290
+ [10, 20]
296
291
  END
297
- bmethod
298
- }
299
-
292
+ var[0] == 0
293
+ }
294
+ end
300
295
 
301
- a = :a
302
- assert_equal <<END.chomp, assertion_message {
303
- a == :b
304
- | |
305
- | false
306
- :a
296
+ t do
297
+ a = 1
298
+ assert_equal <<END.chomp, assertion_message {
299
+ ! a != (+a == -a)
300
+ | | | || | ||
301
+ | | | || | |1
302
+ | | | || | -1
303
+ | | | || false
304
+ | | | |1
305
+ | | | 1
306
+ | | false
307
+ | 1
308
+ false
307
309
  END
308
- a == :b
309
- }
310
+ ! a != (+a == -a)
311
+ }
312
+ end
310
313
 
314
+ t do
315
+ assert_equal <<END.chomp, assertion_message {
316
+ bmethod
317
+ |
318
+ false
319
+ END
320
+ bmethod
321
+ }
322
+ end
311
323
 
312
- assert_equal <<END.chomp, assertion_message {
313
- ! Object
314
- | |
315
- | Object
316
- false
324
+ t do
325
+ a = :a
326
+ assert_equal <<END.chomp, assertion_message {
327
+ a == :b
328
+ | |
329
+ | false
330
+ :a
317
331
  END
318
- ! Object
319
- }
332
+ a == :b
333
+ }
334
+ end
320
335
 
336
+ t do
337
+ assert_equal <<END.chomp, assertion_message {
338
+ ! Object
339
+ | |
340
+ | Object
341
+ false
342
+ END
343
+ ! Object
344
+ }
345
+ end
321
346
 
322
347
  if PowerAssert.respond_to?(:clear_global_method_cache, true)
323
- 3.times do
324
- assert_equal <<END.chomp, assertion_message {
325
- String == Array
326
- | | |
327
- | | Array
328
- | false
329
- String
348
+ t do
349
+ 3.times do
350
+ assert_equal <<END.chomp, assertion_message {
351
+ String == Array
352
+ | | |
353
+ | | Array
354
+ | false
355
+ String
330
356
  END
331
- String == Array
332
- }
357
+ String == Array
358
+ }
359
+ end
333
360
  end
334
361
  end
335
362
  end
336
363
 
337
- def test_inspection_failure
338
- assert_match Regexp.new(<<END.chomp.gsub('|', "\\|")),
364
+ sub_test_case 'inspection_failure' do
365
+ t do
366
+ assert_match Regexp.new(<<END.chomp.gsub('|', "\\|")),
339
367
  assertion_message { BasicObjectSubclass.new.foo }
340
368
  | | |
341
369
  | | "foo"
@@ -343,52 +371,102 @@ END
343
371
  TestPowerAssert::BasicObjectSubclass
344
372
  END
345
373
  assertion_message { BasicObjectSubclass.new.foo }
346
-
347
-
348
- o = Object.new
349
- def o.inspect
350
- raise
351
374
  end
352
- assert_equal <<END.chomp.b, assertion_message {
353
- o.class
354
- | |
355
- | Object
356
- InspectionFailure: RuntimeError:
375
+
376
+ t do
377
+ o = Object.new
378
+ def o.inspect
379
+ raise
380
+ end
381
+ assert_equal <<END.chomp.b, assertion_message {
382
+ o.class
383
+ | |
384
+ | Object
385
+ InspectionFailure: RuntimeError:
357
386
  END
358
- o.class
359
- }
387
+ o.class
388
+ }
389
+ end
360
390
  end
361
391
 
362
- def test_assertion_message_with_incompatible_encodings
363
- if Encoding.default_external == Encoding::UTF_8
364
- a = "\u3042"
365
- def a.inspect
366
- super.encode('utf-16le')
392
+ sub_test_case 'alias_method' do
393
+ def setup
394
+ begin
395
+ PowerAssert.configure do |c|
396
+ c._trace_alias_method = true
397
+ end
398
+ @o = Class.new do
399
+ def foo
400
+ :foo
401
+ end
402
+ alias alias_of_iseq foo
403
+ alias alias_of_cfunc to_s
404
+ end
405
+ yield
406
+ ensure
407
+ PowerAssert.configure do |c|
408
+ c._trace_alias_method = false
409
+ end
367
410
  end
368
- assert_equal <<END.chomp, assertion_message {
369
- a + a
370
- | | |
371
- | | "\u3042"(UTF-16LE)
372
- | "\u3042\u3042"
373
- "\u3042"(UTF-16LE)
411
+ end
412
+
413
+ t do
414
+ assert_match Regexp.new(<<END.chomp.gsub('|', "\\|")),
415
+ assertion_message { @o.new.alias_of_iseq }
416
+ | | |
417
+ | | :foo
418
+ | #<#<Class:.*>:.*>
419
+ #<Class:.*>
374
420
  END
375
- a + a
376
- }
421
+ assertion_message { @o.new.alias_of_iseq }
377
422
  end
378
423
 
424
+ t do
425
+ omit 'alias of cfunc is not supported yet'
426
+ assert_match Regexp.new(<<END.chomp.gsub('|', "\\|")),
427
+ assertion_message { @o.new.alias_of_cfunc }
428
+ | | |
429
+ | | #<#<Class:.*>:.*>
430
+ | #<#<Class:.*>:.*>
431
+ #<Class:.*>
432
+ END
433
+ assertion_message { @o.new.alias_of_cfunc }
434
+ end
435
+ end
379
436
 
380
- a = "\xFF"
381
- def a.inspect
382
- "\xFF".force_encoding('ascii-8bit')
437
+ sub_test_case 'assertion_message_with_incompatible_encodings' do
438
+ if Encoding.default_external == Encoding::UTF_8
439
+ t do
440
+ a = "\u3042"
441
+ def a.inspect
442
+ super.encode('utf-16le')
443
+ end
444
+ assert_equal <<END.chomp, assertion_message {
445
+ a + a
446
+ | | |
447
+ | | "\u3042"(UTF-16LE)
448
+ | "\u3042\u3042"
449
+ "\u3042"(UTF-16LE)
450
+ END
451
+ a + a
452
+ }
453
+ end
383
454
  end
384
- assert_equal <<END.chomp.b, assertion_message {
385
- a.length
386
- | |
387
- | 1
388
- \xFF
455
+
456
+ t do
457
+ a = "\xFF"
458
+ def a.inspect
459
+ "\xFF".force_encoding('ascii-8bit')
460
+ end
461
+ assert_equal <<END.chomp.b, assertion_message {
462
+ a.length
463
+ | |
464
+ | 1
465
+ \xFF
389
466
  END
390
- a.length
391
- }.b
467
+ a.length
468
+ }.b
469
+ end
392
470
  end
393
471
 
394
472
  def test_assertion_message_with_string
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_assert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuki Tsujimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-09 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -70,6 +70,8 @@ files:
70
70
  - LEGAL
71
71
  - README.rdoc
72
72
  - Rakefile
73
+ - benchmarks/bm_yhpg.rb
74
+ - benchmarks/helper.rb
73
75
  - lib/power_assert.rb
74
76
  - lib/power_assert/enable_tracepoint_events.rb
75
77
  - lib/power_assert/version.rb
@@ -99,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
101
  version: '0'
100
102
  requirements: []
101
103
  rubyforge_project:
102
- rubygems_version: 2.5.1
104
+ rubygems_version: 2.6.4
103
105
  signing_key:
104
106
  specification_version: 4
105
107
  summary: Power Assert for Ruby