Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
59e0c262
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
59e0c262
编写于
1月 03, 2013
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove assert_nothing_raised
上级
e3ce5ea3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
49 addition
and
67 deletion
+49
-67
activesupport/test/core_ext/date_ext_test.rb
activesupport/test/core_ext/date_ext_test.rb
+2
-4
activesupport/test/core_ext/date_time_ext_test.rb
activesupport/test/core_ext/date_time_ext_test.rb
+2
-4
activesupport/test/core_ext/numeric_ext_test.rb
activesupport/test/core_ext/numeric_ext_test.rb
+40
-50
activesupport/test/core_ext/time_ext_test.rb
activesupport/test/core_ext/time_ext_test.rb
+2
-4
activesupport/test/core_ext/time_with_zone_test.rb
activesupport/test/core_ext/time_with_zone_test.rb
+2
-4
activesupport/test/inflector_test.rb
activesupport/test/inflector_test.rb
+1
-1
未找到文件。
activesupport/test/core_ext/date_ext_test.rb
浏览文件 @
59e0c262
...
...
@@ -355,10 +355,8 @@ def test_can_freeze_twice
end
def
test_compare_with_infinity
assert_nothing_raised
do
assert_equal
(
-
1
,
Date
.
today
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
Date
.
today
<=>
-
Float
::
INFINITY
)
end
assert_equal
(
-
1
,
Date
.
today
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
Date
.
today
<=>
-
Float
::
INFINITY
)
end
end
...
...
activesupport/test/core_ext/date_time_ext_test.rb
浏览文件 @
59e0c262
...
...
@@ -320,9 +320,7 @@ def with_env_tz(new_tz = 'US/Eastern')
class
DateTimeExtBehaviorTest
<
ActiveSupport
::
TestCase
def
test_compare_with_infinity
assert_nothing_raised
do
assert_equal
(
-
1
,
DateTime
.
now
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
DateTime
.
now
<=>
-
Float
::
INFINITY
)
end
assert_equal
(
-
1
,
DateTime
.
now
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
DateTime
.
now
<=>
-
Float
::
INFINITY
)
end
end
activesupport/test/core_ext/numeric_ext_test.rb
浏览文件 @
59e0c262
...
...
@@ -203,7 +203,7 @@ def gigabytes(number)
def
terabytes
(
number
)
gigabytes
(
number
)
*
1024
end
def
test_to_s__phone
assert_equal
(
"555-1234"
,
5551234
.
to_s
(
:phone
))
assert_equal
(
"800-555-1212"
,
8005551212
.
to_s
(
:phone
))
...
...
@@ -217,7 +217,7 @@ def test_to_s__phone
assert_equal
(
"22-555-1212"
,
225551212
.
to_s
(
:phone
))
assert_equal
(
"+45-22-555-1212"
,
225551212
.
to_s
(
:phone
,
:country_code
=>
45
))
end
def
test_to_s__currency
assert_equal
(
"$1,234,567,890.50"
,
1234567890.50
.
to_s
(
:currency
))
assert_equal
(
"$1,234,567,890.51"
,
1234567890.506
.
to_s
(
:currency
))
...
...
@@ -228,8 +228,8 @@ def test_to_s__currency
assert_equal
(
"$1,234,567,890.5"
,
1234567890.50
.
to_s
(
:currency
,
:precision
=>
1
))
assert_equal
(
"£1234567890,50"
,
1234567890.50
.
to_s
(
:currency
,
:unit
=>
"£"
,
:separator
=>
","
,
:delimiter
=>
""
))
end
def
test_to_s__rounded
assert_equal
(
"-111.235"
,
-
111.2346
.
to_s
(
:rounded
))
assert_equal
(
"111.235"
,
111.2346
.
to_s
(
:rounded
))
...
...
@@ -246,7 +246,7 @@ def test_to_s__rounded
assert_equal
(
"11.00"
,
10.995
.
to_s
(
:rounded
,
:precision
=>
2
))
assert_equal
(
"0.00"
,
-
0.001
.
to_s
(
:rounded
,
:precision
=>
2
))
end
def
test_to_s__percentage
assert_equal
(
"100.000%"
,
100
.
to_s
(
:percentage
))
assert_equal
(
"100%"
,
100
.
to_s
(
:percentage
,
:precision
=>
0
))
...
...
@@ -274,7 +274,7 @@ def test_to_s__delimited__with_options_hash
assert_equal
'12.345.678,05'
,
12345678.05
.
to_s
(
:delimited
,
:separator
=>
','
,
:delimiter
=>
'.'
)
assert_equal
'12.345.678,05'
,
12345678.05
.
to_s
(
:delimited
,
:delimiter
=>
'.'
,
:separator
=>
','
)
end
def
test_to_s__rounded_with_custom_delimiter_and_separator
assert_equal
'31,83'
,
31.825
.
to_s
(
:rounded
,
:precision
=>
2
,
:separator
=>
','
)
...
...
@@ -350,7 +350,7 @@ def test_to_s__human_size_with_si_prefix
assert_equal
'1.23 GB'
,
1234567890
.
to_s
(
:human_size
,
:prefix
=>
:si
)
assert_equal
'1.23 TB'
,
1234567890123
.
to_s
(
:human_size
,
:prefix
=>
:si
)
end
def
test_to_s__human_size_with_options_hash
assert_equal
'1.2 MB'
,
1234567
.
to_s
(
:human_size
,
:precision
=>
2
)
assert_equal
'3 Bytes'
,
3.14159265
.
to_s
(
:human_size
,
:precision
=>
4
)
...
...
@@ -366,13 +366,13 @@ def test_to_s__human_size_with_options_hash
assert_equal
'1.012 KB'
,
kilobytes
(
1.0123
).
to_s
(
:human_size
,
:precision
=>
3
,
:significant
=>
false
)
assert_equal
'1 KB'
,
kilobytes
(
1.0123
).
to_s
(
:human_size
,
:precision
=>
0
,
:significant
=>
true
)
#ignores significant it precision is 0
end
def
test_to_s__human_size_with_custom_delimiter_and_separator
assert_equal
'1,01 KB'
,
kilobytes
(
1.0123
).
to_s
(
:human_size
,
:precision
=>
3
,
:separator
=>
','
)
assert_equal
'1,01 KB'
,
kilobytes
(
1.0100
).
to_s
(
:human_size
,
:precision
=>
4
,
:separator
=>
','
)
assert_equal
'1.000,1 TB'
,
terabytes
(
1000.1
).
to_s
(
:human_size
,
:precision
=>
5
,
:delimiter
=>
'.'
,
:separator
=>
','
)
end
def
test_number_to_human
assert_equal
'-123'
,
-
123
.
to_s
(
:human
)
assert_equal
'-0.5'
,
-
0.5
.
to_s
(
:human
)
...
...
@@ -436,7 +436,7 @@ def test_number_to_human_with_custom_format
def
test_to_s__injected_on_proper_types
assert_equal
Fixnum
,
1230
.
class
assert_equal
'1.23 Thousand'
,
1230
.
to_s
(
:human
)
assert_equal
Float
,
Float
(
1230
).
class
assert_equal
'1.23 Thousand'
,
Float
(
1230
).
to_s
(
:human
)
...
...
@@ -454,60 +454,50 @@ def setup
end
def
test_compare_infinity_with_date
assert_nothing_raised
do
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
Date
.
today
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
Date
.
today
)
assert_equal
(
-
1
,
-
@inf
<=>
Date
.
today
)
assert_equal
(
1
,
@inf
<=>
Date
.
today
)
end
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
Date
.
today
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
Date
.
today
)
assert_equal
(
-
1
,
-
@inf
<=>
Date
.
today
)
assert_equal
(
1
,
@inf
<=>
Date
.
today
)
end
def
test_compare_infinty_with_infinty
assert_nothing_raised
do
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
-
Float
::
INFINITY
)
assert_equal
(
0
,
Float
::
INFINITY
<=>
Float
::
INFINITY
)
assert_equal
(
0
,
-
Float
::
INFINITY
<=>
-
Float
::
INFINITY
)
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
BigDecimal
::
INFINITY
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
-
BigDecimal
::
INFINITY
)
assert_equal
(
0
,
Float
::
INFINITY
<=>
BigDecimal
::
INFINITY
)
assert_equal
(
0
,
-
Float
::
INFINITY
<=>
-
BigDecimal
::
INFINITY
)
assert_equal
(
-
1
,
-
BigDecimal
::
INFINITY
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
BigDecimal
::
INFINITY
<=>
-
Float
::
INFINITY
)
assert_equal
(
0
,
BigDecimal
::
INFINITY
<=>
Float
::
INFINITY
)
assert_equal
(
0
,
-
BigDecimal
::
INFINITY
<=>
-
Float
::
INFINITY
)
end
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
-
Float
::
INFINITY
)
assert_equal
(
0
,
Float
::
INFINITY
<=>
Float
::
INFINITY
)
assert_equal
(
0
,
-
Float
::
INFINITY
<=>
-
Float
::
INFINITY
)
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
BigDecimal
::
INFINITY
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
-
BigDecimal
::
INFINITY
)
assert_equal
(
0
,
Float
::
INFINITY
<=>
BigDecimal
::
INFINITY
)
assert_equal
(
0
,
-
Float
::
INFINITY
<=>
-
BigDecimal
::
INFINITY
)
assert_equal
(
-
1
,
-
BigDecimal
::
INFINITY
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
BigDecimal
::
INFINITY
<=>
-
Float
::
INFINITY
)
assert_equal
(
0
,
BigDecimal
::
INFINITY
<=>
Float
::
INFINITY
)
assert_equal
(
0
,
-
BigDecimal
::
INFINITY
<=>
-
Float
::
INFINITY
)
end
def
test_compare_infinity_with_time
assert_nothing_raised
do
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
Time
.
now
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
Time
.
now
)
assert_equal
(
-
1
,
-
@inf
<=>
Time
.
now
)
assert_equal
(
1
,
@inf
<=>
Time
.
now
)
end
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
Time
.
now
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
Time
.
now
)
assert_equal
(
-
1
,
-
@inf
<=>
Time
.
now
)
assert_equal
(
1
,
@inf
<=>
Time
.
now
)
end
def
test_compare_infinity_with_datetime
assert_nothing_raised
do
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
DateTime
.
now
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
DateTime
.
now
)
assert_equal
(
-
1
,
-
@inf
<=>
DateTime
.
now
)
assert_equal
(
1
,
@inf
<=>
DateTime
.
now
)
end
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
DateTime
.
now
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
DateTime
.
now
)
assert_equal
(
-
1
,
-
@inf
<=>
DateTime
.
now
)
assert_equal
(
1
,
@inf
<=>
DateTime
.
now
)
end
def
test_compare_infinity_with_twz
time_zone
=
ActiveSupport
::
TimeZone
[
'Eastern Time (US & Canada)'
]
twz
=
ActiveSupport
::
TimeWithZone
.
new
(
Time
.
now
,
time_zone
)
assert_nothing_raised
do
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
twz
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
twz
)
assert_equal
(
-
1
,
-
@inf
<=>
twz
)
assert_equal
(
1
,
@inf
<=>
twz
)
end
assert_equal
(
-
1
,
-
Float
::
INFINITY
<=>
twz
)
assert_equal
(
1
,
Float
::
INFINITY
<=>
twz
)
assert_equal
(
-
1
,
-
@inf
<=>
twz
)
assert_equal
(
1
,
@inf
<=>
twz
)
end
end
activesupport/test/core_ext/time_ext_test.rb
浏览文件 @
59e0c262
...
...
@@ -846,9 +846,7 @@ def test_last_quarter_on_31st
class
TimeExtBehaviorTest
<
ActiveSupport
::
TestCase
def
test_compare_with_infinity
assert_nothing_raised
do
assert_equal
(
-
1
,
Time
.
now
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
Time
.
now
<=>
-
Float
::
INFINITY
)
end
assert_equal
(
-
1
,
Time
.
now
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
Time
.
now
<=>
-
Float
::
INFINITY
)
end
end
activesupport/test/core_ext/time_with_zone_test.rb
浏览文件 @
59e0c262
...
...
@@ -1087,9 +1087,7 @@ def test_compare_with_infinity
time_zone
=
ActiveSupport
::
TimeZone
[
'Eastern Time (US & Canada)'
]
twz
=
ActiveSupport
::
TimeWithZone
.
new
(
Time
.
now
,
time_zone
)
assert_nothing_raised
do
assert_equal
(
-
1
,
twz
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
twz
<=>
-
Float
::
INFINITY
)
end
assert_equal
(
-
1
,
twz
<=>
Float
::
INFINITY
)
assert_equal
(
1
,
twz
<=>
-
Float
::
INFINITY
)
end
end
activesupport/test/inflector_test.rb
浏览文件 @
59e0c262
...
...
@@ -361,7 +361,7 @@ def test_inflector_locality
inflect
.
singular
(
/s$/
,
''
)
inflect
.
singular
(
/es$/
,
''
)
inflect
.
irregular
(
'el'
,
'los'
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录