#!/usr/bin/env python
# -*- coding: utf-8 -*-

from runner.koan import *

class AboutStrings(Koan):

    def test_double_quoted_strings_are_strings(self):
        string = "Hello, world."
        self.assertEqual(__, isinstance(string, str))

    def test_single_quoted_strings_are_also_strings(self):
        string = 'Goodbye, world.'
        self.assertEqual(__, isinstance(string, str))

    def test_triple_quote_strings_are_also_strings(self):
        string = """Howdy, world!"""
        self.assertEqual(__, isinstance(string, str))

    def test_triple_single_quotes_work_too(self):
        string = '''Bonjour tout le monde!'''
        self.assertEqual(__, isinstance(string, str))

    def test_raw_strings_are_also_strings(self):
        string = r"Konnichi wa, world!"
        self.assertEqual(__, isinstance(string, str))

    def test_use_single_quotes_to_create_string_with_double_quotes(self):
        string = 'He said, "Go Away."'
        self.assertEqual(__, string)

    def test_use_double_quotes_to_create_strings_with_single_quotes(self):
        string = "Don't"
        self.assertEqual(__, string)

    def test_use_backslash_for_escaping_quotes_in_strings(self):
        a = "He said, \"Don't\""
        b = 'He said, "Don\'t"'
        self.assertEqual(__, (a == b))

    def test_use_backslash_at_the_end_of_a_line_to_continue_onto_the_next_line(self):
        string = "It was the best of times,\n\
It was the worst of times."
        self.assertEqual(__, len(string))

    def test_triple_quoted_strings_can_span_lines(self):
        string = """
Howdy,
world!
"""
        self.assertEqual(__, len(string))

    def test_triple_quoted_strings_need_less_escaping(self):
        a = "Hello \"world\"."
        b = """Hello "world"."""
        self.assertEqual(__, (a == b))

    def test_escaping_quotes_at_the_end_of_triple_quoted_string(self):
        string = """Hello "world\""""
        self.assertEqual(__, string)

    def test_plus_concatenates_strings(self):
        string = "Hello, " + "world"
        self.assertEqual(__, string)

    def test_adjacent_strings_are_concatenated_automatically(self):
        string = "Hello" ", " "world"
        self.assertEqual(__, string)

    def test_plus_will_not_modify_original_strings(self):
        hi = "Hello, "
        there = "world"
        string = hi + there
        self.assertEqual(__, hi)
        self.assertEqual(__, there)

    def test_plus_equals_will_append_to_end_of_string(self):
        hi = "Hello, "
        there = "world"
        hi += there
        self.assertEqual(__, hi)

    def test_plus_equals_also_leaves_original_string_unmodified(self):
        original = "Hello, "
        hi = original
        there = "world"
        hi += there
        self.assertEqual(__, original)

    def test_most_strings_interpret_escape_characters(self):
        string = "\n"
        self.assertEqual('\n', string)
        self.assertEqual("""\n""", string)
        self.assertEqual(__, len(string))

@@ -198,34 +198,36 @@
 elf.assertEqual(
-__
+True
 , isinstance(str
@@ -349,34 +349,36 @@
 elf.assertEqual(
-__
+True
 , isinstance(str
@@ -501,34 +501,36 @@
 elf.assertEqual(
-__
+True
 , isinstance(str
@@ -654,34 +654,36 @@
 elf.assertEqual(
-__
+True
 , isinstance(str
@@ -808,18 +808,20 @@
 rtEqual(
-__
+True
 , isinst
@@ -970,34 +970,53 @@
 elf.assertEqual(
-__
+'He said, %22Go Away.%22'
 , string)%0A%0A    d
@@ -1127,34 +1127,39 @@
 elf.assertEqual(
-__
+%22Don't%22
 , string)%0A%0A    d
@@ -1300,34 +1300,36 @@
 elf.assertEqual(
-__
+True
 , (a == b))%0A%0A   
@@ -1503,34 +1503,34 @@
 elf.assertEqual(
-__
+52
 , len(string))%0A%0A
@@ -1642,34 +1642,34 @@
 elf.assertEqual(
-__
+15
 , len(string))%0A%0A
@@ -1818,18 +1818,20 @@
 rtEqual(
-__
+True
 , (a == 
@@ -1961,34 +1961,52 @@
 elf.assertEqual(
-__
+%22%22%22Hello %22world%5C%22%22%22%22
 , string)%0A%0A    d
@@ -2100,34 +2100,46 @@
 elf.assertEqual(
-__
+%22Hello, world%22
 , string)%0A%0A    d
@@ -2264,18 +2264,30 @@
 rtEqual(
-__
+%22Hello, world%22
 , string
@@ -2443,26 +2443,33 @@
 assertEqual(
-__
+%22Hello, %22
 , hi)%0A      
@@ -2487,18 +2487,23 @@
 rtEqual(
-__
+%22world%22
 , there)
@@ -2657,18 +2657,30 @@
 rtEqual(
-__
+%22Hello, world%22
 , hi)%0A%0A 
@@ -2869,18 +2869,25 @@
 rtEqual(
-__
+%22Hello, %22
 , origin
@@ -3085,10 +3085,9 @@
 ual(
-__
+1
 , le

about strings