ohbarye / pbt

Property-Based Testing tool for Ruby, supporting multiple concurrency methods (Ractor, multiprocesses, multithreads).
https://rubygems.org/gems/pbt
MIT License
207 stars 4 forks source link

Support multiple concurrency methods #13

Closed ohbarye closed 6 months ago

ohbarye commented 6 months ago

Change

Pbt now supports 3 concurrency methods and 1 sequential one. We can choose one of them by setting the concurrency_method option.

The motivation of this change came from 2 points.

  1. Run benchmark to compare which method is the fastest.
  2. Allow to use assertions (expect, eq etc.) in user-defined blocks. It'd be quite hard to run them in isolated Ractor.

Ractor

Pbt.assert(params: { concurrency_method: :ractor }) do
  Pbt.property(Pbt.integer) do |number|
    # ...
  end
end

Process

Pbt.assert(params: { concurrency_method: :process }) do
  Pbt.property(Pbt.integer) do |number|
    # ...
  end
end

Thread

Pbt.assert(params: { concurrency_method: :thread }) do
  Pbt.property(Pbt.integer) do |number|
    # ...
  end
end

None

Pbt.assert(params: { concurrency_method: :none }) do
  Pbt.property(Pbt.integer) do |number|
    # ...
  end
end