forked from milanvrekic/JS-humanize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.html
executable file
·80 lines (76 loc) · 3.03 KB
/
tests.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<script type="text/javascript" src="humanize.min.js"></script>
<script type="text/javascript">
function runTests( tests ) {
document.write( '<table border="1">' );
document.write( '<tr><th>Test</th><th>Result</th></tr>' );
for ( i in tests ) {
document.write( '<tr>' );
tests[ i ] = tests[ i ].replace(/(\r\n|\n|\r)/gm,"\\n");
document.write( '<td>'+tests[ i ]+'</td>' );
document.write( '<td>'+eval( tests[ i ] ).replace(/(<)/gm,"<").replace(/(>)/gm,">")+'</td>' );
document.write( '</tr>' );
}
document.write( '</table>' );
}
var tests = [
'Humanize.intcomma( 4500000 )'
, 'Humanize.intcomma( 450000 )'
, 'Humanize.intcomma( 45000 )'
, 'Humanize.intword( 1000000 )'
, 'Humanize.intword( 1200000 )'
, 'Humanize.intword( 1200000000 )'
, 'Humanize.naturalDay( time() )'
, 'Humanize.naturalDay( time() +60*60*24 )'
, 'Humanize.naturalDay( time() -60*60*24 )'
, 'Humanize.naturalDay( time() -2*60*60*24 )'
, 'Humanize.naturalDay( "13 April 2012" )'
, 'Humanize.naturalDay( "15 April 2012 16:25:30" )'
, 'Humanize.naturalTime( time() )'
, 'Humanize.naturalTime( time() +130 )'
, 'Humanize.naturalTime( time() +70 )'
, 'Humanize.naturalTime( time() +20 )'
, 'Humanize.naturalTime( time() -20 )'
, 'Humanize.naturalTime( time() -70 )'
, 'Humanize.naturalTime( time() -130 )'
, 'Humanize.naturalTime( time() +70 )'
, 'Humanize.naturalTime( time() +130 )'
, 'Humanize.naturalTime( time() +60*20 )'
, 'Humanize.naturalTime( time() +60*60*5 )'
, 'Humanize.naturalTime( time() +60*60*20 )'
, 'Humanize.ordinal( 1 )'
, 'Humanize.ordinal( 2 )'
, 'Humanize.ordinal( 3 )'
, 'Humanize.ordinal( 4 )'
, 'Humanize.ordinal( 11 )'
, 'Humanize.ordinal( 12 )'
, 'Humanize.ordinal( 13 )'
, 'Humanize.ordinal( 14 )'
, 'Humanize.ordinal( 24 )'
, 'Humanize.ordinal( 127 )'
, 'Humanize.filesizeformat( 123456789 )'
, 'Humanize.filesizeformat( 1234567890 )'
, 'Humanize.filesizeformat( 123456 )'
, 'Humanize.filesizeformat( 123 )'
, 'Humanize.linebreaks( "Play\ning with blank lines" )'
, 'Humanize.linebreaks( "Here is what happens\nwhen we add newlines\n\nfollowed by\n\na blank line" )'
, 'Humanize.linebreaksbr( "Play\ning with blank lines" )'
, 'Humanize.linebreaksbr( "Play\n\ning with more \n\nblank lines" )'
, 'Humanize.pluralize( 1 )'
, 'Humanize.pluralize( 2 )'
, 'Humanize.pluralize( 1, "es" )'
, 'Humanize.pluralize( 2, "es" )'
, 'Humanize.pluralize( 1, "y", "ies" )'
, 'Humanize.pluralize( 2, "y", "ies" )'
, 'Humanize.truncatechars( "hello world", 20 )'
, 'Humanize.truncatechars( "hello world", 13 )'
, 'Humanize.truncatechars( "hello world", 10 )'
, 'Humanize.truncatechars( "hello world", 5 )'
, 'Humanize.truncatewords( "Playing with truncate words", 5 )'
, 'Humanize.truncatewords( "Playing with truncate words", 4 )'
, 'Humanize.truncatewords( "Playing with truncate words", 3 )'
, 'Humanize.truncatewords( "Playing with truncate words", 2 )'
, 'Humanize.truncatewords( "Playing with truncate words", 1 )'
, 'Humanize.truncatewords( "Playing with truncate words", 0 )'
];
runTests( tests );
</script>