Initial Revision
[ohcount] / test / unit / matlab_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class MatlabTest < LingoTest
4
5         def test_line_comment_1
6                 lb = [Ohcount::LanguageBreakdown.new("matlab", "", "%comment", 0)]
7                 assert_equal lb, Ohcount::parse(" %comment", "matlab")
8         end
9
10         def test_line_comment_2
11                 lb = [Ohcount::LanguageBreakdown.new("matlab", "", "%comment", 0)]
12                 assert_equal lb, Ohcount::parse("%comment", "matlab")
13         end
14
15         def test_octave_syntax_comment
16                 lb = [Ohcount::LanguageBreakdown.new("matlab", "", "#comment", 0)]
17                 assert_equal lb, Ohcount::parse(" #comment", "matlab")
18         end
19
20         # matlab is slightly weird in that '%' starts a line comment
21         # while '{%' starts a block comment. To make sure we aren't
22         # misinterpreting '{%' as a line comment, the following test
23         # adds code after a single-line block comment. If it interprets the
24         # {% as a line comment (ie: just %) then it will ignore everything else
25         # after and attribute the line as comment
26         def test_false_line_comment
27                 lb = [Ohcount::LanguageBreakdown.new("matlab", "{%block%} code", "", 0)]
28                 assert_equal lb, Ohcount::parse(" {%block%} code", "matlab")
29         end
30
31         def test_comprehensive
32                 verify_parse("matlab1.m", 'matlab')
33         end
34 end