|
|
2d8b32 |
From 9b34e37d7ecfa750f5185a0e16df1c131732e318 Mon Sep 17 00:00:00 2001
|
|
|
2d8b32 |
From: Joshua Peek <josh@joshpeek.com>
|
|
|
2d8b32 |
Date: Mon, 17 Feb 2014 17:30:04 -0600
|
|
|
2d8b32 |
Subject: [PATCH] Fix assertions
|
|
|
2d8b32 |
|
|
|
2d8b32 |
---
|
|
|
2d8b32 |
test/test_coffee_script.rb | 18 +++++++++++-------
|
|
|
2d8b32 |
1 file changed, 11 insertions(+), 7 deletions(-)
|
|
|
2d8b32 |
|
|
|
2d8b32 |
diff --git a/test/test_coffee_script.rb b/test/test_coffee_script.rb
|
|
|
2d8b32 |
index d43fbea..ad3c692 100644
|
|
|
2d8b32 |
--- a/test/test_coffee_script.rb
|
|
|
2d8b32 |
+++ b/test/test_coffee_script.rb
|
|
|
2d8b32 |
@@ -17,42 +17,46 @@
|
|
|
2d8b32 |
|
|
|
2d8b32 |
class TestCoffeeScript < TestCase
|
|
|
2d8b32 |
def test_compile
|
|
|
2d8b32 |
- assert_equal "(function() {\n puts('Hello, World!');\n}).call(this);\n",
|
|
|
2d8b32 |
+ assert_match "puts('Hello, World!')",
|
|
|
2d8b32 |
CoffeeScript.compile("puts 'Hello, World!'\n")
|
|
|
2d8b32 |
end
|
|
|
2d8b32 |
|
|
|
2d8b32 |
def test_compile_with_io
|
|
|
2d8b32 |
io = StringIO.new("puts 'Hello, World!'\n")
|
|
|
2d8b32 |
- assert_equal "(function() {\n puts('Hello, World!');\n}).call(this);\n",
|
|
|
2d8b32 |
+ assert_match "puts('Hello, World!')",
|
|
|
2d8b32 |
CoffeeScript.compile(io)
|
|
|
2d8b32 |
end
|
|
|
2d8b32 |
|
|
|
2d8b32 |
def test_compile_with_bare_true
|
|
|
2d8b32 |
- assert_equal "puts('Hello, World!');",
|
|
|
2d8b32 |
+ assert_no_match "function()",
|
|
|
2d8b32 |
CoffeeScript.compile("puts 'Hello, World!'\n", :bare => true)
|
|
|
2d8b32 |
end
|
|
|
2d8b32 |
|
|
|
2d8b32 |
def test_compile_with_bare_false
|
|
|
2d8b32 |
- assert_equal "(function() {\n puts('Hello, World!');\n}).call(this);\n",
|
|
|
2d8b32 |
+ assert_match "function()",
|
|
|
2d8b32 |
CoffeeScript.compile("puts 'Hello, World!'\n", :bare => false)
|
|
|
2d8b32 |
end
|
|
|
2d8b32 |
|
|
|
2d8b32 |
def test_compile_with_no_wrap_true
|
|
|
2d8b32 |
- assert_equal "puts('Hello, World!');",
|
|
|
2d8b32 |
+ assert_no_match "function()",
|
|
|
2d8b32 |
CoffeeScript.compile("puts 'Hello, World!'\n", :no_wrap => true)
|
|
|
2d8b32 |
end
|
|
|
2d8b32 |
|
|
|
2d8b32 |
def test_compile_with_no_wrap
|
|
|
2d8b32 |
- assert_equal "(function() {\n puts('Hello, World!');\n}).call(this);\n",
|
|
|
2d8b32 |
+ assert_match "function()",
|
|
|
2d8b32 |
CoffeeScript.compile("puts 'Hello, World!'\n", :no_wrap => false)
|
|
|
2d8b32 |
end
|
|
|
2d8b32 |
|
|
|
2d8b32 |
def test_compilation_error
|
|
|
2d8b32 |
- assert_raise CoffeeScript::CompilationError do
|
|
|
2d8b32 |
+ assert_raises CoffeeScript::CompilationError do
|
|
|
2d8b32 |
CoffeeScript.compile("unless")
|
|
|
2d8b32 |
end
|
|
|
2d8b32 |
end
|
|
|
2d8b32 |
|
|
|
2d8b32 |
+ def assert_no_match(expected, actual)
|
|
|
2d8b32 |
+ assert !expected.match(actual)
|
|
|
2d8b32 |
+ end
|
|
|
2d8b32 |
+
|
|
|
2d8b32 |
def assert_exception_does_not_match(pattern)
|
|
|
2d8b32 |
yield
|
|
|
2d8b32 |
flunk "no exception raised"
|
|
|
2d8b32 |
--
|
|
|
2d8b32 |
1.9.3
|
|
|
2d8b32 |
|