Created
July 5, 2011 00:43
-
-
Save pocket7878/1064112 to your computer and use it in GitHub Desktop.
Define little test's for prelude.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git spec/prelude.vim spec/prelude.vim | |
index bee45d1..f44de4b 100644 | |
--- spec/prelude.vim | |
+++ spec/prelude.vim | |
@@ -2,6 +2,96 @@ source spec/base.vim | |
let g:V = vital#of('vital') | |
+"Test of wrapper function for type()"{{{ | |
+Context Prelude.is_numeric() | |
+ It checks if the argument is a numeric | |
+ Should g:V.is_numeric(3) ==# 1 | |
+ Should g:V.is_numeric(3.14159) ==# 1 | |
+ Should g:V.is_numeric("") ==# 0 | |
+ Should g:V.is_numeric(function('tr')) ==# 0 | |
+ Should g:V.is_numeric([]) ==# 0 | |
+ Should g:V.is_numeric({}) ==# 0 | |
+ End | |
+End | |
+ | |
+Context Prelude.is_integer() | |
+ It checks if the argument is an integer | |
+ Should g:V.is_integer(3) ==# 1 | |
+ Should g:V.is_integer(3.14159) ==# 0 | |
+ Should g:V.is_integer("") ==# 0 | |
+ Should g:V.is_integer(function('tr')) ==# 0 | |
+ Should g:V.is_integer([]) ==# 0 | |
+ Should g:V.is_integer({}) ==# 0 | |
+ End | |
+End | |
+ | |
+Context Prelude.is_number() | |
+ It checks if the argument is a number | |
+ Should g:V.is_number(3) ==# 1 | |
+ Should g:V.is_number(3.14159) ==# 0 | |
+ Should g:V.is_number("") ==# 0 | |
+ Should g:V.is_number(function('tr')) ==# 0 | |
+ Should g:V.is_number([]) ==# 0 | |
+ Should g:V.is_number({}) ==# 0 | |
+ End | |
+End | |
+ | |
+Context Prelude.is_float() | |
+ It checks if the argument is a float | |
+ Should g:V.is_float(3) ==# 0 | |
+ Should g:V.is_float(3.14159) ==# 1 | |
+ Should g:V.is_float("") ==# 0 | |
+ Should g:V.is_float(function('tr')) ==# 0 | |
+ Should g:V.is_float([]) ==# 0 | |
+ Should g:V.is_float({}) ==# 0 | |
+ End | |
+End | |
+ | |
+Context Prelude.is_string() | |
+ It checks if the argument is a string | |
+ Should g:V.is_string(3) ==# 0 | |
+ Should g:V.is_string(3.14159) ==# 0 | |
+ Should g:V.is_string("") ==# 1 | |
+ Should g:V.is_string(function('tr')) ==# 0 | |
+ Should g:V.is_string([]) ==# 0 | |
+ Should g:V.is_string({}) ==# 0 | |
+ End | |
+End | |
+ | |
+Context Prelude.is_funcref() | |
+ It checks if the argument is a funcref | |
+ Should g:V.is_funcref(3) ==# 0 | |
+ Should g:V.is_funcref(3.14159) ==# 0 | |
+ Should g:V.is_funcref("") ==# 0 | |
+ Should g:V.is_funcref(function('tr')) ==# 1 | |
+ Should g:V.is_funcref([]) ==# 0 | |
+ Should g:V.is_funcref({}) ==# 0 | |
+ End | |
+End | |
+ | |
+Context Prelude.is_list() | |
+ It checks if the argument is a list | |
+ Should g:V.is_list(3) ==# 0 | |
+ Should g:V.is_list(3.14159) ==# 0 | |
+ Should g:V.is_list("") ==# 0 | |
+ Should g:V.is_list(function('tr')) ==# 0 | |
+ Should g:V.is_list([]) ==# 1 | |
+ Should g:V.is_list({}) ==# 0 | |
+ End | |
+End | |
+ | |
+Context Prelude.is_dict() | |
+ It checks if the argument is a dictionary | |
+ Should g:V.is_dict(3) ==# 0 | |
+ Should g:V.is_dict(3.14159) ==# 0 | |
+ Should g:V.is_dict("") ==# 0 | |
+ Should g:V.is_dict(function('tr')) ==# 0 | |
+ Should g:V.is_dict([]) ==# 0 | |
+ Should g:V.is_dict({}) ==# 1 | |
+ End | |
+End | |
+"}}} | |
+ | |
Context Prelude.truncate() | |
It truncates not based on the number of letters but based on visual length | |
Should g:V.truncate('あいうえお', 2) ==# 'あ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment