annotate src/testdir/test_reltime.vim @ 17049:f38fcbf343ce v8.1.1524

patch 8.1.1524: tests are silently skipped commit https://github.com/vim/vim/commit/b0f94c1ff34d27d33aa9f96204985ea29c2eb0a1 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 13 22:19:53 2019 +0200 patch 8.1.1524: tests are silently skipped Problem: Tests are silently skipped. Solution: Throw an exception for skipped tests in more places.
author Bram Moolenaar <Bram@vim.org>
date Thu, 13 Jun 2019 22:30:07 +0200
parents ea504064c996
children 8e9e9124c7a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7981
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for reltime()
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
17049
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 9228
diff changeset
3 if !has('reltime')
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 9228
diff changeset
4 throw 'Skipped, reltime feature missing'
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 9228
diff changeset
5 endif
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 9228
diff changeset
6 if !has('float')
f38fcbf343ce patch 8.1.1524: tests are silently skipped
Bram Moolenaar <Bram@vim.org>
parents: 9228
diff changeset
7 throw 'Skipped, float feature missing'
7981
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 endif
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 func Test_reltime()
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 let now = reltime()
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 sleep 10m
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 let later = reltime()
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 let elapsed = reltime(now)
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_true(reltimestr(elapsed) =~ '0\.0')
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_true(reltimestr(elapsed) != '0.0')
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_true(reltimefloat(elapsed) < 0.1)
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_true(reltimefloat(elapsed) > 0.0)
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 let same = reltime(now, now)
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal('0.000', split(reltimestr(same))[0][:4])
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal(0.0, reltimefloat(same))
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 let differs = reltime(now, later)
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call assert_true(reltimestr(differs) =~ '0\.0')
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call assert_true(reltimestr(differs) != '0.0')
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_true(reltimefloat(differs) < 0.1)
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call assert_true(reltimefloat(differs) > 0.0)
a5f1bdd2007b commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endfunc