Add bin and edit workflow
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s

This commit is contained in:
2026-09-16 13:11:16 -06:00
parent c8ac4fcae5
commit 4cee170d66
17576 changed files with 895740 additions and 2 deletions
@@ -0,0 +1,18 @@
covers 'facets/time/ago'
test_case Time do
# We do not need to test #ago b/c it is an alias for #less.
# One test is provided to add to coverage report.
method :ago do
test "is an alias of #less" do
t = Time.utc(2010,01,20,12,00,00)
t.ago(1, :year).year.assert = 2009
t.ago(2, :years).year.assert = 2008
end
end
end
@@ -0,0 +1,17 @@
covers 'facets/time/change'
test_case Time do
method :change do
test do
t = Time.local(2006,04,20,15,37)
n = Time.now
n = n.change(:month=>4, :day=>20, :hour=>15, :min=>37, :year=>2006)
n.assert == t
end
end
end
@@ -0,0 +1,19 @@
covers 'facets/time/dst_adjustment'
test_case Time do
# TODO: Is Time#dst_adjustment test correct?
method :dst_adjustment do
test do
t0 = Time.utc(2010,01,20,12,00,00)
t1 = Time.utc(2010,06,20,12,00,00)
tt = t1.dst_adjustment(t0)
tt.assert == t0
tt = t0.dst_adjustment(t1)
tt.assert == t1
end
end
end
@@ -0,0 +1,15 @@
covers 'facets/time/elapse'
test_case Time do
class_method :elapse do
test do
t = Time.elapse { sleep 1 }
assert( (t > 0.9) && (t < 2.1 ))
end
end
end
@@ -0,0 +1,32 @@
covers 'facets/time/future'
test_case Time do
method :future? do
test do
t = Time.now + 1000
t.assert.future?
end
test do
n = Time.now - 1000
n.refute.future?
end
test do
n = Time.now + 1001
t = Time.now + 1000
n.assert.future?(t)
end
test do
n = Time.now + 999
t = Time.now + 1000
n.refute.future?(t)
end
end
end
@@ -0,0 +1,18 @@
covers 'facets/time/hence'
test_case Time do
# We do not need to test #hence b/c it is an alias for #shift.
# One test is provided to add to coverage report.
method :hence do
test do
e = Time.utc(2008,11, 1, 18,30,57)
r = Time.utc(2007,11, 1, 18,30,57).hence(1, :years)
r.assert == e
end
end
end
@@ -0,0 +1,18 @@
covers 'facets/time/ago'
test_case Time do
# We do not need to test #in b/c it is an alias for #shift.
# One test is provided to add to coverage report.
method :in do
test do
e = Time.utc(2008,11, 1, 18,30,57)
r = Time.utc(2007,11, 1, 18,30,57).in(1, :years)
r.assert == e
end
end
end
@@ -0,0 +1,139 @@
covers 'facets/time/less'
test_case Time do
method :less do
setup "January 20th 2010 at Noon" do
@t = Time.utc(2010,01,20,12,00,00)
end
test 'years' do
@t.less(1, :year).year.assert = 2009
@t.less(2, :years).year.assert = 2008
end
test 'weeks' do
@t.less(1, :week).day.assert == 13
@t.less(2, :weeks).day.assert == 6
end
test 'days' do
@t.less(1, :day).day.assert == 19
@t.less(2, :days).day.assert == 18
end
test 'hours' do
@t.less(1, :hour).hour.assert == 11
@t.less(2, :hours).hour.assert == 10
@t.less(12, :hours).hour.assert == 0
end
test 'minutes' do
@t.less(1, :minute).min.assert == 59
@t.less(2, :minutes).min.assert == 58
@t.less(60, :minutes).min.assert == 0
end
test 'seconds' do
@t.less(1, :second).sec.assert == 59
@t.less(2, :seconds).sec.assert == 58
@t.less(60, :seconds).sec.assert == 0
end
end
method :less do
concern "verify via dates"
test "change years" do
e = Time.utc(2007,11, 1, 18,30,57)
r = Time.utc(2008,11, 1, 18,30,57).less(1, :years)
r.assert == e
end
test "change weeks" do
e = Time.utc(2008,11,24, 18,30,57)
r = Time.utc(2008,12, 1, 18,30,57).less(1, :weeks)
r.assert == e
end
test "change days" do
e = Time.utc(2008,11,30, 18,30,57)
r = Time.utc(2008,12, 1, 18,30,57).less(1, :days)
r.assert == e
end
test "change hours" do
e = Time.utc(2008,11,30, 23,30,57)
r = Time.utc(2008,12, 1, 0,30,57).less(1, :hours)
r.assert == e
end
test "change minutes" do
e = Time.utc(2008,11,30, 23,58,57)
r = Time.utc(2008,12, 1, 0, 0,57).less(2, :minutes)
r.assert == e
end
test "change seconds" do
e = Time.utc(2008,11,30, 23,59,57)
r = Time.utc(2008,12, 1, 0, 0, 1).less(4, :seconds)
r.assert == e
end
end
method :less do
concern "months do not have a fixed duration"
test "change month no year wrap" do
e = Time.utc(2008,11, 1)
r = Time.utc(2008,12, 1).less(1, :months)
r.assert == e
end
test "change month with year wrap due to month" do
e = Time.utc(2007,12, 1)
r = Time.utc(2008, 1, 1).less(1, :months)
r.assert == e
end
test "change month with 12 or more converts extra months into a year adjustment" do
e = Time.utc(2007, 1, 1)
r = Time.utc(2008, 1, 1).less(12, :months)
r.assert == e
e = Time.utc(2006,11, 1)
r = Time.utc(2008,12, 1).less(25, :months)
r.assert == e
end
# 13 months = 1 year + 1 month AND month changing from 12 to 1,
# when going backward, means going back 1 extra year.
test "change month with 12 or more AND year wrap due to month" do
e = Time.utc(2006,12, 1)
r = Time.utc(2008, 1, 1).less(13, :months)
r.assert == e
end
test "smaller units should remain unchanged" do
e = Time.utc(2005, 8,20, 15,37,59)
r = Time.utc(2006, 1,20, 15,37,59).less(5, :months)
r.assert == e
end
test "passing a negative number to #less should be same as a positive number to #shift" do
e = Time.utc(2008, 1, 1)
r = Time.utc(2006,12, 1).less(-13, :months)
r.assert == e
r = Time.utc(2006,12, 1).shift(13, :months)
r.assert == e
end
end
end
@@ -0,0 +1,32 @@
covers 'facets/time/past'
test_case Time do
method :past? do
test do
t = Time.now - 1000
t.assert.past?
end
test do
n = Time.now + 1000
n.refute.past?
end
test do
n = Time.now - 1001
t = Time.now - 1000
n.assert.past?(t)
end
test do
n = Time.now - 999
t = Time.now - 1000
n.refute.past?(t)
end
end
end
@@ -0,0 +1,34 @@
covers 'facets/time/round_to'
test_case Time do
method :round_to do
setup do
@t = Time.local(2000,03,03,3,37,23)
end
test "hour" do
@t.round_to(60 * 60).assert == Time.local(2000,03,03,4, 0)
end
#test "month" do
# @t.round_to(1.month).assert == Time.local(2000,03,03,3, 0)
#end
test "15 minutes" do
@t.round_to(15 * 60).assert == Time.local(2000,03,03,3,30)
end
test "10 minutes" do
@t.round_to(10 * 60).assert == Time.local(2000,03,03,3,40)
end
test "5 minutes" do
@t.round_to(5 * 60).assert == Time.local(2000,03,03,3,35)
end
end
end
@@ -0,0 +1,43 @@
covers 'facets/time/set'
test_case Time do
method :set do
setup do
@t = Time.utc(2010,10,01,12,15,0)
end
test 'year' do
x = @t.set(:year=>2020)
x.year.assert == 2020
end
test 'month' do
x = @t.set(:month=>11)
x.month.assert == 11
end
test 'day' do
x = @t.set(:day=>15)
x.day.assert == 15
end
test 'hours' do
x = @t.set(:hour=>12)
x.hour.assert == 12
end
test 'minutes' do
x = @t.set(:minutes=>12)
x.min.assert == 12
end
test 'seconds' do
x = @t.set(:seconds=>9)
x.sec.assert == 9
end
end
end
@@ -0,0 +1,135 @@
covers 'facets/time/shift'
test_case Time do
method :shift do
setup "January 1st 2010 at Noon" do
@t = Time.utc(2010,01,01, 12,00,00)
end
test 'years' do
@t.shift(1, :year).year.assert = 2011
@t.shift(2, :years).year.assert = 2012
end
test 'weeks' do
@t.shift(1, :week).day.assert == 8
@t.shift(2, :weeks).day.assert == 15
end
test 'days' do
@t.shift(1, :day).day.assert == 2
@t.shift(2, :days).day.assert == 3
end
test 'hours' do
@t.shift(1, :hour).hour.assert == 13
@t.shift(2, :hours).hour.assert == 14
@t.shift(12, :hours).hour.assert == 0
end
test 'minutes' do
@t.shift(1, :minute).min.assert == 1
@t.shift(2, :minutes).min.assert == 2
@t.shift(60, :minutes).min.assert == 0
end
test 'seconds' do
@t.shift(1, :second).sec.assert == 1
@t.shift(2, :seconds).sec.assert == 2
@t.shift(60, :seconds).sec.assert == 0
end
end
method :shift do
test "change years" do
e = Time.utc(2008,11, 1, 18,30,57)
r = Time.utc(2007,11, 1, 18,30,57).shift(1, :years)
r.assert == e
end
test "change weeks" do
e = Time.utc(2008,12, 1, 18,30,57)
r = Time.utc(2008,11,24, 18,30,57).shift(1, :weeks)
r.assert == e
end
test "change days" do
e = Time.utc(2008,12, 1, 18,30,57)
r = Time.utc(2008,11,30, 18,30,57).shift(1, :days)
r.assert == e
end
test "change hours" do
e = Time.utc(2008,12, 1, 0,30,57)
r = Time.utc(2008,11,30, 23,30,57).shift(1, :hours)
r.assert == e
end
test "change minutes" do
e = Time.utc(2008,12, 1, 0, 0,57)
r = Time.utc(2008,11,30, 23,58,57).shift(2, :minutes)
r.assert == e
end
test "change seconds" do
e = Time.utc(2008,12, 1, 0, 0, 1)
r = Time.utc(2008,11,30, 23,59,57).shift(4, :seconds)
r.assert == e
end
end
# months are more difficult, so they get their own section
method :shift do
test "change month no year wrap" do
e = Time.utc(2008,12, 1)
r = Time.utc(2008,11, 1).shift(1, :months)
r.assert == e
end
test "change month with year wrap due to month" do
e = Time.utc(2008, 1, 1)
r = Time.utc(2007,12, 1).shift(1, :months)
r.assert == e
end
test "change month with 12 or more converts extra months into a year adjustment" do
e = Time.utc(2008, 1, 1)
r = Time.utc(2007, 1, 1).shift(12, :months)
r.assert == e
e = Time.utc(2008,12, 1)
r = Time.utc(2006,11, 1).shift(25, :months)
r.assert == e
end
test "change month with 12 or more AND year wrap due to month" do
e = Time.utc(2008, 1, 1)
r = Time.utc(2006,12, 1).shift(13, :months)
r.assert == e
end
test "smaller units should remain unchanged" do
e = Time.utc(2006, 1,20, 15,37,59)
r = Time.utc(2005, 8,20, 15,37,59).shift(5, :months)
r.assert == e
end
test "passing a negative number to #shift should be same as a positive number to #ago" do
e = Time.utc(2005, 8,20)
r = Time.utc(2006, 1,20).shift(-5, :months)
r.assert == e
r = Time.utc(2006, 1,20).ago(5, :months)
r.assert == e
end
end
end
@@ -0,0 +1,42 @@
covers 'facets/time/stamp'
test_case Time do
method :stamp do
test "default" do
t = Time.utc(2005,4,20,15,37)
t.stamp.assert == "2005-04-20 15:37:00 +0000"
end
test "ruby18" do
t = Time.utc(2005,4,20,15,37)
t.stamp(:ruby18).assert == "Wed Apr 20 15:37:00 +0000 2005"
end
test "long format" do
t = Time.utc(2005,4,20,15,37)
t.stamp(:long).assert == "April 20, 2005 15:37"
end
test "short format" do
t = Time.utc(2005,4,20,15,37)
t.stamp(:short).assert == "20 Apr 15:37"
end
end
class_method :stamp do
test "long format" do
Time.stamp(:long)
end
test "short format" do
Time.stamp(:short)
end
end
end
@@ -0,0 +1,15 @@
covers 'facets/time/to_time'
test_case Time do
method :to_time do
test do
t = Time.now
t.to_time.assert.is_a?(Time)
end
end
end
@@ -0,0 +1,34 @@
covers 'facets/time/trunc'
test_case Time do
method :trunc do
setup do
@t = Time.local(2000,03,03,3,37,23)
end
test "hour" do
@t.trunc(60 * 60).assert == Time.local(2000,03,03,3, 0)
end
#test "month" do
# @t.trunc(1.month).assert == Time.local(2000,03,01,0, 0)
#end
test "15 minutes" do
@t.trunc(15 * 60).assert == Time.local(2000,03,03,3,30)
end
test "10 minutes" do
@t.trunc(10 * 60).assert == Time.local(2000,03,03,3,30)
end
test "05 minutes" do
@t.trunc(5 * 60).assert == Time.local(2000,03,03,3,35)
end
end
end