Permalink
Browse files

Failing tests for comment parser

  • Loading branch information...
1 parent 6c58c80 commit 67be7b4e3673f6b83791db69487a1882503914b4 @kneath committed Feb 6, 2012
Showing with 83 additions and 0 deletions.
  1. +50 −0 test/comment_parser_test.rb
  2. +33 −0 test/fixtures/comments.txt
View
50 test/comment_parser_test.rb
@@ -0,0 +1,50 @@
+require 'test/helper'
+
+class CommentParser < Kss::Test
+
+ def setup
+ loc = 'test/fixtures/comments.txt'
+ @parsed_comments = Kss::CommentParser.new(loc).blocks
+ end
+
+ test "finds single-line comment styles" do
+ expected = <<comment
+This comment block has comment identifiers on every line.
+
+Fun fact: this is Kyle's favorite comment syntax!
+comment
+ assert @parsed_comments.include? expected.rstrip
+ end
+
+ test "finds block-style comment styles" do
+ expected = <<comment
+This comment block is a block-style comment syntax.
+
+There's only two identifier across multiple lines.
+comment
+ assert @parsed_comments.include? expected.rstrip
+
+
+ expected = <<comment
+This is another common multi-line comment style.
+
+It has stars at the begining of every line.
+comment
+ assert @parsed_comments.include? expected.rstrip
+
+ end
+
+ test "handles mixed styles" do
+ expected = "This comment has a /* comment */ identifier inside of it!"
+ assert @parsed_comments.include? expected
+
+ expected = "Look at my //cool// comment art!"
+ assert @parsed_comments.include? expected
+ end
+
+ test "handles indented comments" do
+ assert @parsed_comments.include? "Indented single-line comment."
+ assert @parsed_comments.include? "Indented block comment."
+ end
+
+end
View
33 test/fixtures/comments.txt
@@ -0,0 +1,33 @@
+This file is used for generic comment parsing across CSS, SCSS, SASS & LESS.
+
+There's single-line comment styles:
+
+// This comment block has comment identifiers on every line.
+//
+// Fun fact: this is Kyle's favorite comment syntax!
+
+
+There's block comment styles:
+
+/* This comment block is a block-style comment syntax.
+
+There's only two identifier across multiple lines. */
+
+/* This is another common multi-line comment style.
+ *
+ * It has stars at the begining of every line.
+ */
+
+
+Some people do crazy things like mix comment styles:
+
+// This comment has a /* comment */ identifier inside of it!
+
+/* Look at my //cool// comment art! */
+
+
+Indented comments:
+
+ // Indented single-line comment.
+
+ /* Indented block comment. */

0 comments on commit 67be7b4

Please sign in to comment.