Граф коммитов

20 Коммитов

Автор SHA1 Сообщение Дата
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
marcandre 487736646a * lib/prime.rb: Add basic argument checking to Prime.prime?
[Bug #11606]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-20 03:19:44 +00:00
nobu 2c3656f5e8 test: refine assertions
* test/test_prime.rb (test_eratosthenes_works_fine_after_timeout):
  use assert_raise to check timeout.

* test/test_securerandom.rb: check if results are hexadecimal
  strings, and refine failure messages.

* test/test_tracer.rb (test_tracer_with_option_r_without_gems):
  use assert_equal to compare.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 05:26:31 +00:00
nobu 31637f00fc test_prime.rb: cosmetic changes
* test/test_prime.rb (test_eratosthenes_works_fine_after_timeout):
  use spaces instead of TABs in ruby codes.  [Fix GH-944]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 05:14:18 +00:00
nobu 0b2f4ab07e test_prime.rb: descriptive assertions
* test/test_prime.rb: use more descriptive assertions for better
  failure meessages, instead of simple assert.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14 12:13:04 +00:00
marcandre b28f3e5c4f * lib/prime.rb: Return sized enumerators.
Patch by Kenichi Kamiya [GH-931]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-12 15:45:59 +00:00
marcandre 5b78e48c31 * lib/prime.rb: Fix with_object with no block given
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-12 15:45:44 +00:00
marcandre dd8f914d3b * lib/prime.rb: Have with_index accept an offset parameter.
Based on patch by T Yamada. [#11007]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-12 15:45:22 +00:00
nobu ae042f21fb use assert_raise
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 02:18:44 +00:00
marcandre d2487ed475 * lib/prime.rb: Remove obsolete Prime.new
patch by Ajay Kumar. [Fixes GH-891]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-22 13:36:39 +00:00
ayumin bef8e4557c * lib/prime.rb (Prime#prime?): negative numbers can't be primes
by definition. reported by Ivan Kataitsev. [Bug #7395]
* test/test_prime.rb: add test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-08 18:22:29 +00:00
yugui def83bff91 * lib/prime.rb (Prime::EratosthenesGenerator,
Prime::EratosthenesSieve): New implementation by
  robertjlooby <robertjlooby AT gmail.com>.

* test/test_prime.rb: updated with new method name

commit 4b6090ea852d63b26e02796c69b41caa0fa95077
Merge: ceda881 c8f7809
Author: Yuki Sonoda (Yugui) <yugui@yugui.jp>
Date:   Mon Jul 15 12:50:04 2013 +0900

    Merge commit 'c8f780987fbdfbae428977487e1cf793c4c36d3f'

    Conflicts:
    	lib/prime.rb

commit c8f780987fbdfbae428977487e1cf793c4c36d3f
Author: robertjlooby <robertjlooby@gmail.com>
Date:   Thu Jun 27 23:04:45 2013 -0500

    updated test/test_prime.rb with new method name

commit 996517bdbb3108cd1687d99613b69e539eb1567b
Author: robertjlooby <robertjlooby@gmail.com>
Date:   Thu Jun 27 22:59:39 2013 -0500

    new implementation of Prime::EratosthenesGenerator and Prime::EratosthenesSieve

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 04:21:34 +00:00
nobu b16fc57852 * test/syck/test_string.rb (Syck::TestString#test_non_binary_string):
use assert_not instead of refute, unless required minitest
 directly.
* test/test_prime.rb (TestPrime::sieve.Integer): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-13 00:56:44 +00:00
yugui a33353f880 * test/test_prime.rb (TestPrime#test_new): the warning expected have
not been displayed when $VERBOSE == nil. Patch by Shota Fukumori
  a.k.a. sora_h. [ruby-dev:42272]
  Recovers $stderr even if StringIO.new fails. Reported by unak.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-22 08:03:55 +00:00
akr 37679ee584 supress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-25 23:12:50 +00:00
yugui c0b42eedea * test/test_prime.rb
(TestPrime#test_eratosthenes_works_fine_after_timeout):
  test for [ruby-dev:39465].

* lib/prime.rb (Prime::EratosthenesSieve):
  fixed [ruby-dev:39465].
  suppressed memory reallocation.
  constantified some magic numbers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-18 00:55:34 +00:00
yugui 7287b852da * lib/prime.rb (Prime#prime_division): now decomposes
negative integer into a decomposition with element [-1, 1].

* test/test_prime.rb: test for it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-13 13:51:49 +00:00
nobu 287a34ae0d * {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06 03:56:38 +00:00
yugui 294f45b0fc * lib/prime.rb (Prime::prime?): used to return a wrong answer.
[ruby-core:22646].

* test/test_prime.rb (test_prime?): test case for [ruby-core:22646].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-03 15:57:15 +00:00
yugui fce093432e * lib/mathn.rb (Integer): moved into prime.rb.
(Prime): ditto.

* lib/prime.rb (Integer): moved from mathn.rb.
  (Integer.each_prime): added.
  (Integer#prime?): added.
  (Prime): moved from mathn.rb.
    Its implmentation was rewritten. see [ruby-dev:35863].
    And patched by Keiju ISHITSUKA <keiju@ishitsuka.com>,
    see [ruby-dev:36128].
  (Prime.new):                     obsolete.
  (Prime.instance):                added.
  (Prime.each):                    added.
  (Prime.int_from_prime_division): added.
  (Prime.prime_division):          added.
  (Prime.prime?):                  added.
    Patch by TOYOFUKU Chikanobu
    <nobu_toyofuku at nifty.com> in [ruby-dev:36067].
  (Prime.cache):                   removed.
  (Prime.primes):                  removed.
  (Prime.primes_so_far):           removed.
  (Prime#int_from_prime_division): added.
  (Prime#prime_division):          added.
  (Prime#prime?):                  added.
  (Prime#primes):                  removed.
  (Prime#primes_so_far):           removed.
  (Prime::PseudoPrmeGenerator):    added.
  (Prime::EratosthenesGenerator):  added.
  (Prime::TrialDivisionGenerator): added.
  (Prime::Generator23):            added.
  (Prime::TrialDivision):          added.
    Extracted from the previous implementation of Prime
    by Keiju ISHITSUKA.
  (Prime::EratosthenesSieve):      added.

* lib/.document (prime.rb): added

* lib/README (prime.rb): added

* test/test_prime.rb: added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 13:57:21 +00:00