fUnit 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -4
- data/Rakefile +7 -2
- data/bin/funit +3 -0
- data/docs/html/classes/Funit.html +48 -48
- data/docs/html/classes/Funit/Assertions.html +56 -54
- data/docs/html/classes/Funit/Compiler.html +6 -6
- data/docs/html/classes/Funit/Depend.html +60 -60
- data/docs/html/classes/Funit/TestSuite.html +48 -48
- data/docs/html/classes/String.html +170 -0
- data/docs/html/created.rid +1 -1
- data/docs/html/files/README.html +2 -11
- data/docs/html/files/lib/funit/assertions_rb.html +8 -1
- data/docs/html/fr_class_index.html +1 -0
- data/docs/html/fr_method_index.html +34 -33
- data/lib/funit/assertions.rb +42 -13
- data/tests/tc_compile.rb +22 -22
- data/tests/tc_fortran_deps.rb +139 -132
- data/tests/tc_funit.rb +91 -92
- data/tests/tc_test_suite.rb +83 -83
- data/utils/funit-mode.el +115 -0
- metadata +4 -2
data/tests/tc_test_suite.rb
CHANGED
@@ -8,104 +8,104 @@ require 'funit/assertions'
|
|
8
8
|
|
9
9
|
class TestTestSuite < Test::Unit::TestCase
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def create_funit_file funit_contents
|
26
|
-
File.open('dummyf90test.f90','w') do |f|
|
27
|
-
f.puts "module dummyf90test\nend module dummyf90test"
|
11
|
+
def setup
|
12
|
+
File.rm_f(*Dir["dummyf90test*"])
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
File.rm_f(*Dir["dummyf90test*"])
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_nonexistent_funit_file_is_not_created
|
20
|
+
Funit::TestSuite.new 'dummyf90test'
|
21
|
+
assert !File.exists?("dummyf90test.fun")
|
22
|
+
assert !File.exists?("dummyf90test_fun.f90")
|
28
23
|
end
|
29
|
-
|
30
|
-
|
24
|
+
|
25
|
+
def create_funit_file funit_contents
|
26
|
+
File.open('dummyf90test.f90','w') do |f|
|
27
|
+
f.puts "module dummyf90test\nend module dummyf90test"
|
28
|
+
end
|
29
|
+
File.open('dummyf90test.fun','w') do |f|
|
30
|
+
f.puts funit_contents
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
@@compileCommand = "#{Funit::Compiler.new.name} -c dummyf90test.f90 dummyf90test_fun.f90"
|
35
|
+
|
36
|
+
def test_bare_minimum_funit_file_compiles
|
37
|
+
create_funit_file ""
|
38
|
+
Funit::TestSuite.new 'dummyf90test'
|
39
|
+
assert system(@@compileCommand)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_module_variables_allowed
|
43
|
+
create_funit_file "integer :: a"
|
44
|
+
Funit::TestSuite.new 'dummyf90test'
|
45
|
+
assert system(@@compileCommand)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_blank_setup_compiles
|
49
|
+
create_funit_file "beginSetup\nendSetup"
|
50
|
+
Funit::TestSuite.new 'dummyf90test'
|
51
|
+
assert system(@@compileCommand)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_blank_test_gives_warning
|
55
|
+
create_funit_file "beginTest bob\nendTest"
|
56
|
+
Funit::TestSuite.new 'dummyf90test'
|
57
|
+
assert system(@@compileCommand)
|
31
58
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def test_module_variables_allowed
|
43
|
-
create_funit_file "integer :: a"
|
44
|
-
Funit::TestSuite.new 'dummyf90test'
|
45
|
-
assert system(@@compileCommand)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_blank_setup_compiles
|
49
|
-
create_funit_file "beginSetup\nendSetup"
|
50
|
-
Funit::TestSuite.new 'dummyf90test'
|
51
|
-
assert system(@@compileCommand)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_blank_test_gives_warning
|
55
|
-
create_funit_file "beginTest bob\nendTest"
|
56
|
-
Funit::TestSuite.new 'dummyf90test'
|
57
|
-
assert system(@@compileCommand)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_single_assert_test_compiles
|
61
|
-
create_funit_file "beginTest assertTrue\nIsTrue(.true.)\nendTest"
|
62
|
-
Funit::TestSuite.new 'dummyf90test'
|
63
|
-
assert system(@@compileCommand)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_matrix_assert_compiles
|
67
|
-
create_funit_file <<-MATRIX
|
59
|
+
|
60
|
+
def test_single_assert_test_compiles
|
61
|
+
create_funit_file "beginTest assertTrue\nIsTrue(.true.)\nendTest"
|
62
|
+
Funit::TestSuite.new 'dummyf90test'
|
63
|
+
assert system(@@compileCommand)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_matrix_assert_compiles
|
67
|
+
create_funit_file <<-MATRIX
|
68
68
|
beginTest assertTrue
|
69
69
|
integer :: a(2,2)
|
70
70
|
a = 1
|
71
71
|
IsEqual(a(1,1),1)
|
72
72
|
endTest
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
MATRIX
|
74
|
+
Funit::TestSuite.new 'dummyf90test'
|
75
|
+
assert system(@@compileCommand)
|
76
|
+
end
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
def test_simple_real_equals_assert_works
|
79
|
+
create_funit_file <<-REALEQUALS
|
80
80
|
beginTest assert_equals
|
81
81
|
real :: real_var
|
82
82
|
real_var = 1.0
|
83
83
|
IsRealEqual(real_var,1.0)
|
84
84
|
endTest
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
function balance( left, right)
|
93
|
-
real :: balance
|
94
|
-
real, intent(in) :: left, right
|
95
|
-
balance = 0.5*(left+right)
|
96
|
-
end function balance
|
85
|
+
REALEQUALS
|
86
|
+
Funit::TestSuite.new 'dummyf90test'
|
87
|
+
assert system(@@compileCommand)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_real_equals_assert_works_with_function
|
91
|
+
create_funit_file <<-REQUALSFUNC
|
97
92
|
beginTest assert_equals_for_function
|
98
93
|
IsRealEqual(balance(0.0,0.0),0.0)
|
99
94
|
endTest
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
95
|
+
function balance( left, right)
|
96
|
+
real :: balance
|
97
|
+
real, intent(in) :: left, right
|
98
|
+
balance = 0.5*(left+right)
|
99
|
+
end function balance
|
100
|
+
REQUALSFUNC
|
101
|
+
Funit::TestSuite.new 'dummyf90test'
|
102
|
+
assert system(@@compileCommand)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_ignore_commented_test
|
106
|
+
create_funit_file "XbeginTest bob\nendTest"
|
107
|
+
Funit::TestSuite.new 'dummyf90test'
|
108
|
+
assert_no_match( /Testbob/i, IO.readlines('dummyf90test_fun.f90').join )
|
109
|
+
end
|
110
110
|
|
111
111
|
end
|
data/utils/funit-mode.el
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
;; 'funit-mode.el' - a derived major mode for editing fUnit files
|
2
|
+
;;
|
3
|
+
;; $Id: funit-mode.el 157 2006-04-16 01:02:21Z kleb $
|
4
|
+
;;
|
5
|
+
;; INSTALLATION:
|
6
|
+
;;
|
7
|
+
;; Copy 'funit-mode.el' to the system site-lisp directory, e.g.,
|
8
|
+
;;
|
9
|
+
;; /usr/share/emacs/site-lisp
|
10
|
+
;;
|
11
|
+
;; or, if you do not have root permission, somewhere local
|
12
|
+
;; and set the load-path search variable in your ~/.emacs file
|
13
|
+
;; accordingly, e.g.,
|
14
|
+
;;
|
15
|
+
;; (setq load-path (append load-path '("~/lisp")))
|
16
|
+
;;
|
17
|
+
;; Then, to automatically activate funit-mode when visiting files,
|
18
|
+
;; add the following lines to your ~/.emacs file:
|
19
|
+
;;
|
20
|
+
;; (autoload 'funit-mode "funit-mode"
|
21
|
+
;; "Mode for editing fUnit files.")
|
22
|
+
;; (setq auto-mode-alist
|
23
|
+
;; (cons '("\\.fun$" . funit-mode) auto-mode-alist))
|
24
|
+
|
25
|
+
(define-derived-mode funit-mode
|
26
|
+
f90-mode "fUnit"
|
27
|
+
"Major mode for fUnit files (derived from F90 mode).\n\n
|
28
|
+
\\{funit-mode-map}"
|
29
|
+
(interactive)
|
30
|
+
(message "fUnit mode.")
|
31
|
+
)
|
32
|
+
|
33
|
+
;; add some new font-locks to f90's extensive list
|
34
|
+
(font-lock-add-keywords 'funit-mode
|
35
|
+
'(("\\<IsFalse\\>" . font-lock-function-name-face)
|
36
|
+
("\\<IsEqual\\>" . font-lock-function-name-face)
|
37
|
+
("\\<IsRealEqual\\>" . font-lock-function-name-face)
|
38
|
+
("\\<IsTrue\\>" . font-lock-function-name-face)
|
39
|
+
("\\<IsEqualWithin\\>" . font-lock-function-name-face)
|
40
|
+
("\\<beginTest\\>" . font-lock-builtin-face)
|
41
|
+
("\\<endTest\\>" . font-lock-builtin-face)
|
42
|
+
("\\<beginTeardown\\>" . font-lock-builtin-face)
|
43
|
+
("\\<endTeardown\\>" . font-lock-builtin-face)
|
44
|
+
("\\<beginSetup\\>" . font-lock-builtin-face)
|
45
|
+
("\\<endSetup\\>" . font-lock-builtin-face))
|
46
|
+
)
|
47
|
+
|
48
|
+
(defvar funit-buffer-command "funit"
|
49
|
+
"Shell command used by the \\[funit-test-buffer] function.")
|
50
|
+
|
51
|
+
;;(defvar compilation-buffer-name-function "* fUnit output *")
|
52
|
+
|
53
|
+
;; run fUnit on the current buffer:
|
54
|
+
(defun funit-test-buffer ()
|
55
|
+
"Excute \\[funit-buffer-command] on the file associated
|
56
|
+
with the current buffer."
|
57
|
+
(interactive)
|
58
|
+
; (compile funit-buffer-command);; (file-name-nondirectory buffer-file-name)))
|
59
|
+
(save-buffer)
|
60
|
+
(shell-command-on-region (point-min) (point-max) funit-buffer-command funit-error-buffer)
|
61
|
+
)
|
62
|
+
|
63
|
+
;; key-binding for running fUnit on the current buffer
|
64
|
+
(define-key funit-mode-map "\C-c\C-c" 'funit-test-buffer)
|
65
|
+
|
66
|
+
;; add fUnit error regex to compilation mode:
|
67
|
+
;; blah, blah, blak [FluxFunctions.fun:34]
|
68
|
+
;(require 'compile)
|
69
|
+
;(setq compilation-error-regexp-alist
|
70
|
+
; (cons '("\\[\\(.+\\):\\([0-9]+\\)\\]" 1 2) compilation-error-regexp-alist)
|
71
|
+
;)
|
72
|
+
|
73
|
+
|
74
|
+
(defvar funit-error-buffer
|
75
|
+
"*fUnit output-buffer*"
|
76
|
+
"Buffer name for error messages used by `funit-next-error'")
|
77
|
+
|
78
|
+
(defvar funit-error-message-regexp
|
79
|
+
"\\[.+:\\([0-9]+\\)\\]"
|
80
|
+
"Regular expression used by `funit-next-error' to find error messages.
|
81
|
+
The sub-expression between the first capturing parens must be the line
|
82
|
+
number where the error occured")
|
83
|
+
|
84
|
+
|
85
|
+
(defun funit-next-error ()
|
86
|
+
"Goto line in current buffer indicated by next error message in `funit-error-buffer'
|
87
|
+
|
88
|
+
Assumes that the point is positioned before the first occurance of
|
89
|
+
`funit-error-message-regexp' in the `funit-error-buffer' before the first
|
90
|
+
call to this function.
|
91
|
+
|
92
|
+
See also `funit-error-message-regexp' `funit-error-buffer'"
|
93
|
+
|
94
|
+
(interactive)
|
95
|
+
(let ((error-line-number))
|
96
|
+
(save-current-buffer
|
97
|
+
(set-buffer (or (get-buffer funit-error-buffer)
|
98
|
+
(error
|
99
|
+
(concat
|
100
|
+
"Can't find the error buffer: "
|
101
|
+
funit-error-buffer))))
|
102
|
+
(if (re-search-forward funit-error-message-regexp nil t)
|
103
|
+
(progn
|
104
|
+
(setq error-line-number
|
105
|
+
(string-to-number
|
106
|
+
(buffer-substring (match-beginning 1)
|
107
|
+
(match-end 1))))
|
108
|
+
(goto-char (1+ (match-end 1))))))
|
109
|
+
(if error-line-number
|
110
|
+
(goto-line error-line-number)
|
111
|
+
(message "No more errors"))))
|
112
|
+
|
113
|
+
(provide 'funit-mode)
|
114
|
+
|
115
|
+
;; end of 'funit-mode.el'
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: fUnit
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2006-04-
|
6
|
+
version: 0.1.1
|
7
|
+
date: 2006-04-18 00:00:00 -04:00
|
8
8
|
summary: A Fortran Unit Testing Framework
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- docs/html/rdoc-style.css
|
50
50
|
- docs/html/classes/Funit
|
51
51
|
- docs/html/classes/Funit.html
|
52
|
+
- docs/html/classes/String.html
|
52
53
|
- docs/html/classes/Funit/Assertions.html
|
53
54
|
- docs/html/classes/Funit/Compiler.html
|
54
55
|
- docs/html/classes/Funit/Depend.html
|
@@ -104,6 +105,7 @@ files:
|
|
104
105
|
- tests/tc_funit.rb
|
105
106
|
- tests/tc_test_suite.rb
|
106
107
|
- tests/ts_funit.rb
|
108
|
+
- utils/funit-mode.el
|
107
109
|
test_files:
|
108
110
|
- tests/ts_funit.rb
|
109
111
|
rdoc_options:
|