probatio 1.4.1 → 1.5.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
  SHA256:
3
- metadata.gz: c910c5674405102137f008c16c94908088831536430f839c39a4802509c8a709
4
- data.tar.gz: b32eab00ef03d092f94aba817d0c537eeb0d5e39b816b22dce0bed9137bd825c
3
+ metadata.gz: 5afa6aef3d22540ead334ee7074be169452a44fedc2fe108f1bbad73ceed428e
4
+ data.tar.gz: ee04395a9682d0a3565f3cc531caf78fbee33878b90ea7578cd3101fadda0803
5
5
  SHA512:
6
- metadata.gz: 22f07a3b6ee491c3c2e580dd04d11ad379ea9f05ab4bd7ed39446bc7bb600af1c6dba17001a5d61f2cd6f4b36a4ab8803e5f8de9c9788443e5ceb915e8b7bac8
7
- data.tar.gz: 0ae5c5537465bffa1b4fe8de09836a6f67c6a0499952e9684ef060e6d66c83aeba8ec35249c91d847d7f40035431ea4227859d56cceb8cf69fc7aca9a7e2037a
6
+ metadata.gz: 94f56b66f3a4e464a4b89df1fcd621f24bf7e8c6b6934b1d5abb254cbd1aad5ddd2dde5d897b287f477b0544414a935604509c084b68810f08debfa09eb36abb
7
+ data.tar.gz: 7fe7a7322ea1c881ed3dc04535054074c86ffc029e857e268ecee84bc730dfed6c4580a63ec2d30efe296f1d5bd8e089f8ae2038486ccb54bbd133ef2f3ad18c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## probatio 1.5.0 released 2026-01-28
6
+
7
+ * Introduce `assert_not_match`
8
+ * Introduce `time do; end` helper
9
+ * Alias `assert_class` to `assert_instance_of`
10
+
11
+
12
+ ## probatio 1.4.2 released 2025-11-26
13
+
14
+ * Allow pointing at a group with a line number between tests
15
+
16
+
5
17
  ## probatio 1.4.1 released 2025-11-16
6
18
 
7
19
  * Fixed assert_error versus no errors
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2024-2025, John Mettraux, jmettraux+flor@gmail.com
2
+ Copyright (c) 2024-2026, John Mettraux, jmettraux+flor@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -86,6 +86,14 @@ class Probatio::Context
86
86
  a.end_with?(sta) }
87
87
  end
88
88
 
89
+ def assert_not_match(*as)
90
+
91
+ strings, others = as.partition { |a| a.is_a?(String) }
92
+ rex = others.find { |o| o.is_a?(Regexp) } || strings.pop
93
+
94
+ do_assert(strings, 'not matched') { |s| ! s.match?(rex) }
95
+ end
96
+
89
97
  def assert_include(*as)
90
98
 
91
99
  ai =
@@ -124,6 +132,7 @@ class Probatio::Context
124
132
  do_assert(as, 'instance of') { |e| e.is_a?(moc) }
125
133
  end
126
134
  alias assert_is_a assert_instance_of
135
+ alias assert_class assert_instance_of
127
136
 
128
137
  def assert_error(*as, &block)
129
138
 
@@ -18,6 +18,24 @@ module Probatio::Helpers
18
18
 
19
19
  Gem.win_platform?
20
20
  end
21
+
22
+ def time(&block)
23
+
24
+ t0 = Probatio.monow
25
+
26
+ block.call
27
+
28
+ d = Probatio.monow - t0
29
+ ds = Probatio.to_time_s(d)
30
+
31
+ s, l = block.source_location
32
+
33
+ puts(
34
+ "\n" +
35
+ Probatio.c.dark_grey +
36
+ "time block at #{s}:#{l} took #{ds}" +
37
+ Probatio.c.reset)
38
+ end
21
39
  end
22
40
 
23
41
 
data/lib/probatio.rb CHANGED
@@ -18,7 +18,7 @@ require 'probatio/more'
18
18
 
19
19
  module Probatio
20
20
 
21
- VERSION = '1.4.1'
21
+ VERSION = '1.5.0'
22
22
 
23
23
  class << self
24
24
 
@@ -101,6 +101,8 @@ module Probatio
101
101
  read_test_file(root_group, fpath)
102
102
  end
103
103
 
104
+ rework_line_numbers(root_group)
105
+
104
106
  run_opts[:filen] = rework_filen(root_group, run_opts)
105
107
 
106
108
  dbg_s { Cerata.vertical_h_to_s(run_opts, ' run_opts| ') }
@@ -200,7 +202,9 @@ module Probatio
200
202
  fmap = map[fn[0]]
201
203
  fline = fn[1]
202
204
 
203
- n = fmap.find { |l0, l1, n| fline >= l0 && (fline <= l1 || l1 < 1) }
205
+ n = fmap
206
+ .select { |l0, l1, n| fline >= l0 && (fline <= l1 || l1 < 1) }
207
+ .last
204
208
 
205
209
  return [ fn ] if n && n[2].is_a?(Probatio::Test)
206
210
 
@@ -235,6 +239,32 @@ module Probatio
235
239
 
236
240
  fs.any? ? fs : do_locate(File.dirname(dir), suffixes)
237
241
  end
242
+
243
+ def rework_line_numbers(root_group)
244
+
245
+ # if the start line is 0, set it to the end line
246
+ # if the end line is 0, set it to the file's last line
247
+ #
248
+ root_group.map.each do |path, groups|
249
+ groups.each do |llg|
250
+ llg[0] = llg[1] if llg[0] == 0
251
+ llg[1] = File.readlines(path).count if llg[1] == 0
252
+ end
253
+ end
254
+
255
+ # ensure that group end lines are their last child's end line
256
+ #
257
+ root_group
258
+ .map
259
+ .inject([]) { |a, (_, groups)|
260
+ groups.each { |llg| a << llg if llg[2].is_a?(Probatio::Group) }
261
+ a }
262
+ .reverse
263
+ .each { |llg|
264
+ g = llg[2]; next if g.name == '_'
265
+ lc = g.children.last
266
+ llg[1] = lc.last_line if lc }
267
+ end
238
268
  end
239
269
 
240
270
  class Node
@@ -348,6 +378,7 @@ module Probatio
348
378
 
349
379
  f0 = f.last
350
380
  f0[1] = (l == 0 ? f0[0] : l - 1) if f0
381
+ # sets the last line of the previous node...
351
382
 
352
383
  f << [ l, 0, self ]
353
384
  end
@@ -582,6 +613,8 @@ module Probatio
582
613
 
583
614
  def test(name, opts={}, &block)
584
615
 
616
+ opts[:pending] = true if block.nil?
617
+
585
618
  @children << Probatio::Test.new(self, @path, name.to_s, opts, block)
586
619
  end
587
620
  end
@@ -660,10 +693,8 @@ module Probatio
660
693
 
661
694
  def path_and_line_match?(fpath, fline)
662
695
 
663
- #p [ path, line, last_line, '<-->', fpath, fline ]
664
- line &&
665
- path == fpath &&
666
- fline >= line && fline <= last_line
696
+ path == fpath &&
697
+ fline && line && fline >= line && fline <= last_line
667
698
  end
668
699
 
669
700
  def in_setup?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: probatio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-11-16 00:00:00.000000000 Z
11
+ date: 2026-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stringio