1 require File.dirname(__FILE__) + '/../test_helper'
3 class Ohcount::MatlabTest < Ohcount::Test
5 def test_line_comment_1
6 lb = [Ohcount::LanguageBreakdown.new("matlab", "", "%comment", 0)]
7 assert_equal lb, Ohcount::parse(" %comment", "matlab")
10 def test_line_comment_2
11 lb = [Ohcount::LanguageBreakdown.new("matlab", "", "%comment", 0)]
12 assert_equal lb, Ohcount::parse("%comment", "matlab")
15 def test_octave_syntax_comment
16 lb = [Ohcount::LanguageBreakdown.new("matlab", "", "#comment", 0)]
17 assert_equal lb, Ohcount::parse(" #comment", "matlab")
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")
31 def test_comprehensive
32 verify_parse("matlab1.m", 'matlab')