CustomSourceCodeSelectionTests.st
changeset 712 3ede18c143a2
parent 702 186940d3ac86
child 713 fe6e07e51f22
--- a/CustomSourceCodeSelectionTests.st	Mon Oct 27 10:14:55 2014 +0100
+++ b/CustomSourceCodeSelectionTests.st	Tue Oct 28 14:43:57 2014 +0100
@@ -55,6 +55,83 @@
     "Created: / 24-08-2014 / 22:57:47 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
 !
 
+test_print_on_all_filled
+    | expectedString actualString stream |
+
+    expectedString := 'a CustomSourceCodeSelection (selectedInterval: 2 to:5; ',
+        'currentSourceCode: test_print_on_all_filled ^ 265; ',
+        'selectedMethod: a Method(CustomSourceCodeSelectionTests test_print_on_all_filled); ',
+        'selectedClass: CustomSourceCodeSelectionTests; selectedSelector: test_print_on_all_filled)'.
+
+    stream := WriteStream on:(String new).
+
+    codeSelection
+        selectedClass: self class;
+        selectedMethod: (self class compiledMethodAt: #test_print_on_all_filled);
+        selectedInterval: (2 to: 5);
+        selectedSelector: #test_print_on_all_filled;
+        currentSourceCode: 'test_print_on_all_filled ^ 265';
+        yourself.
+
+    codeSelection printOn:stream.    
+
+    actualString := stream contents.
+    
+    self assert: expectedString = actualString.
+
+    "Modified: / 28-10-2014 / 10:27:40 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_selected_selector_from_method
+    | expectedSelector actualSelector |
+
+    expectedSelector := #test_selected_selector_from_method.
+    codeSelection selectedMethod: (self class compiledMethodAt: #test_selected_selector_from_method).
+
+    actualSelector := codeSelection selectedSelector.
+
+    self assert: expectedSelector = actualSelector.
+
+    "Created: / 28-10-2014 / 09:31:45 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_selected_selector_from_source
+    | expectedSelector actualSelector |
+
+    expectedSelector := #test_selector_01.
+    codeSelection currentSourceCode: 'test_selector_01 ^ 101'.
+
+    actualSelector := codeSelection selectedSelector.
+
+    self assert: expectedSelector = actualSelector.
+
+    "Created: / 28-10-2014 / 10:52:31 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_selected_selector_known
+    | expectedSelector actualSelector |
+
+    expectedSelector := #selector_01.
+    codeSelection selectedSelector: expectedSelector.
+
+    actualSelector := codeSelection selectedSelector.
+
+    self assert: expectedSelector = actualSelector.
+
+    "Created: / 28-10-2014 / 09:30:30 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_selected_selector_unknown
+    | expectedSelector actualSelector |
+
+    expectedSelector := nil.
+    actualSelector := codeSelection selectedSelector.
+
+    self assert: expectedSelector = actualSelector.
+
+    "Created: / 28-10-2014 / 09:29:36 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
 test_selected_source_code_part_code
 
     codeSelection
@@ -113,13 +190,17 @@
 !
 
 test_selected_source_unknown
+    | expectedSource |
+
+    expectedSource := 'selector ^ self otherSelector.'.
 
     codeSelection
-        currentSourceCode: 'selector ^ self otherSelector.'.
+        currentSourceCode: expectedSource.
 
-    self assert: codeSelection selectedSourceCode isNil.
+    self assert: expectedSource = (codeSelection selectedSourceCode).
 
     "Created: / 14-10-2014 / 10:19:44 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+    "Modified: / 28-10-2014 / 09:13:24 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
 ! !
 
 !CustomSourceCodeSelectionTests class methodsFor:'documentation'!