Mercurial > vim
annotate src/testdir/test_reltime.vim @ 9015:42b228c8701b v7.4.1793
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Apr 26 21:39:13 2016 +0200
patch 7.4.1793
Problem: Some character classes may differ between systems. On OS/X the
regexp test fails.
Solution: Make this less dependent on the system. (idea by Kazunobu Kuriyama)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 26 Apr 2016 21:45:05 +0200 |
parents | a5f1bdd2007b |
children | ea504064c996 |
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 |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 if !has('reltime') || !has('float') |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 finish |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 endif |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 func Test_reltime() |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 let now = reltime() |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 sleep 10m |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 let later = reltime() |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 let elapsed = reltime(now) |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call assert_true(reltimestr(elapsed) =~ '0\.0') |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 call assert_true(reltimestr(elapsed) != '0.0') |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_true(reltimefloat(elapsed) < 0.1) |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call assert_true(reltimefloat(elapsed) > 0.0) |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 let same = reltime(now, now) |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 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
|
19 call assert_equal(0.0, reltimefloat(same)) |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 let differs = reltime(now, later) |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 call assert_true(reltimestr(differs) =~ '0\.0') |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 call assert_true(reltimestr(differs) != '0.0') |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 call assert_true(reltimefloat(differs) < 0.1) |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 call assert_true(reltimefloat(differs) > 0.0) |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 |
a5f1bdd2007b
commit https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 endfunc |