How to use setCursorPosition method in qawolf

Best JavaScript code snippet using qawolf

test_ruby.py

Source:test_ruby.py Github

copy

Full Screen

...16 " if foo",17 " blah",18 ""]19 self.setOrigin(origin)20 self.setCursorPosition(0, 8)21 self.enter()22 self.type("blah")23 self.verifyExpected(expected)24 def test_if11(self):25 origin = [26 " if foo",27 " blah",28 ""]29 expected = [30 " if foo",31 " blah",32 " end",33 ""]34 self.setOrigin(origin)35 self.setCursorPosition(1, 8)36 self.enter()37 self.type("end")38 self.verifyExpected(expected)39 @unittest.expectedFailure40 def test_if20(self):41 origin = [42 " var = if foo",43 ""]44 expected = [45 " var = if foo",46 " blah",47 ""]48 self.setOrigin(origin)49 self.setCursorPosition(0, 14)50 self.enter()51 self.type("blah")52 self.verifyExpected(expected)53 @unittest.expectedFailure54 def test_if21(self):55 origin = [56 " var = if foo",57 " blah",58 ""]59 expected = [60 " var = if foo",61 " blah",62 " end",63 ""]64 self.setOrigin(origin)65 self.setCursorPosition(1, 8)66 self.enter()67 self.type("end")68 self.verifyExpected(expected)69 def test_if22(self):70 origin = [71 " var = bar if foo",72 ""]73 expected = [74 " var = bar if foo",75 " blah",76 ""]77 self.setOrigin(origin)78 self.setCursorPosition(0, 18)79 self.enter()80 self.type("blah")81 self.verifyExpected(expected)82 def test_if30(self):83 origin = [84 " if foo; 42 else 37 end",85 ""]86 expected = [87 " if foo; 42 else 37 end",88 " blah",89 ""]90 self.setOrigin(origin)91 self.setCursorPosition(0, 24)92 self.enter()93 self.type("blah")94 self.verifyExpected(expected)95 def test_if31(self):96 origin = [97 " if foo then 42 else 37 end",98 ""]99 expected = [100 " if foo then 42 else 37 end",101 " blah",102 ""]103 self.setOrigin(origin)104 self.setCursorPosition(0, 28)105 self.enter()106 self.type("blah")107 self.verifyExpected(expected)108class Block(BaseTestClass):109 @unittest.expectedFailure110 def test_block01(self):111 origin = [112 "10.times {",113 " foo",114 ""]115 expected = [116 "10.times {",117 " foo",118 " blah",119 ""]120 self.setOrigin(origin)121 self.setCursorPosition(1, 6)122 self.enter()123 self.type("blah")124 self.verifyExpected(expected)125 @unittest.expectedFailure126 def test_block02(self):127 origin = [128 "10.times {",129 " if foo",130 ""]131 expected = [132 "10.times {",133 " if foo",134 " blah",135 ""]136 self.setOrigin(origin)137 self.setCursorPosition(1, 8)138 self.enter()139 self.type("blah")140 self.verifyExpected(expected)141class Basic(BaseTestClass):142 def test_basic1(self):143 origin = [144 "# basic1.txt",145 ""]146 expected = [147 "# basic1.txt",148 "def foo",149 " if gets",150 " puts",151 " else",152 " exit",153 " end",154 "end",155 ""]156 self.setOrigin(origin)157 self.setCursorPosition(0, 12)158 self.enter()159 self.type("def foo")160 self.enter()161 self.type("if gets")162 self.enter()163 self.type("puts")164 self.enter()165 self.type("else")166 self.enter()167 self.type("exit")168 self.enter()169 self.type("end")170 self.enter()171 self.type("end")172 self.verifyExpected(expected)173 @unittest.expectedFailure174 def test_basic2(self):175 origin = [176 "# basic2.txt",177 "",178 ""]179 expected = [180 "# basic2.txt",181 "",182 "class MyClass",183 "",184 " attr_reader :foo",185 "",186 " private",187 "",188 " def helper(str)",189 ' puts "helper(#{str})"',190 " end",191 "",192 "end",193 ""]194 self.setOrigin(origin)195 self.setCursorPosition(1, 0)196 self.enter()197 self.type("class MyClass")198 self.enter()199 self.enter()200 self.type("attr_reader :foo")201 self.enter()202 self.enter()203 self.type("private")204 self.enter()205 self.enter()206 self.type("def helper(str)")207 self.enter()208 self.type("puts \"helper(#{str})\"")209 self.enter()210 self.type("end")211 self.enter()212 self.enter()213 self.type("end")214 self.verifyExpected(expected)215 def test_basic3(self):216 origin = [217 "def foo",218 " if check",219 " bar",220 ""]221 expected = [222 "def foo",223 " if check",224 " bar",225 " end",226 "end",227 ""]228 self.setOrigin(origin)229 self.setCursorPosition(2, 10)230 self.enter()231 self.type("end")232 self.enter()233 self.type("end")234 self.verifyExpected(expected)235 def test_basic4(self):236 origin = [237 "def foo",238 " array.each do |v|",239 " bar",240 ""]241 expected = [242 "def foo",243 " array.each do |v|",244 " bar",245 " end",246 "end",247 ""]248 self.setOrigin(origin)249 self.setCursorPosition(2, 21)250 self.enter()251 self.type("end")252 self.enter()253 self.type("end")254 self.verifyExpected(expected)255class EmptyFile(BaseTestClass):256 def test_empty_file1(self):257 origin = [258 "",259 ""]260 expected = [261 "",262 "",263 "# Comment",264 "def foo",265 " bar",266 "end",267 ""]268 self.setOrigin(origin)269 self.setCursorPosition(0, 0)270 self.enter()271 self.enter()272 self.type("# Comment")273 self.enter()274 self.type("def foo")275 self.enter()276 self.type("bar")277 self.enter()278 self.type("end")279 self.verifyExpected(expected)280class RegExp(BaseTestClass):281 def test_regexp1(self):282 origin = [283 " rx =~ /^hello/",284 ""]285 expected = [286 " rx =~ /^hello/",287 " foo",288 ""]289 self.setOrigin(origin)290 self.setCursorPosition(0, 16)291 self.enter()292 self.type("foo")293 self.verifyExpected(expected)294class Do(BaseTestClass):295 def test_do1(self):296 origin = [297 "# do1.txt",298 "5.times do",299 ""]300 expected = [301 "# do1.txt",302 "5.times do",303 "end",304 ""]305 self.setOrigin(origin)306 self.setCursorPosition(1, 24)307 self.enter()308 self.type("end")309 self.verifyExpected(expected)310 def test_do2(self):311 origin = [312 "# do2.txt",313 'File.open("file") do |f|',314 ""]315 expected = [316 "# do2.txt",317 'File.open("file") do |f|',318 " f << foo",319 "end",320 ""]321 self.setOrigin(origin)322 self.setCursorPosition(1, 24)323 self.enter()324 self.type("f << foo")325 self.enter()326 self.type("end")327 self.verifyExpected(expected)328 def test_do3(self):329 origin = [330 "# do3.txt",331 "[1,2,3].each_with_index do |obj, i|",332 ""]333 expected = [334 "# do3.txt",335 "[1,2,3].each_with_index do |obj, i|",336 ' puts "#{i}: #{obj.inspect}"',337 "end",338 ""]339 self.setOrigin(origin)340 self.setCursorPosition(1, 35)341 self.enter()342 self.type("puts \"#{i}: #{obj.inspect}\"")343 self.enter()344 self.type("end")345 self.verifyExpected(expected)346 def test_do4(self):347 origin = [348 "# do4.txt",349 'File.open("#{base}.txt") do |f|',350 ""]351 expected = [352 "# do4.txt",353 'File.open("#{base}.txt") do |f|',354 " f",355 "end",356 ""]357 self.setOrigin(origin)358 self.setCursorPosition(1, 31)359 self.enter()360 self.type("f")361 self.enter()362 self.type("end")363 self.verifyExpected(expected)364 def test_do5(self):365 origin = [366 "def foo(f)",367 " f.each do # loop",368 ""]369 expected = [370 "def foo(f)",371 " f.each do # loop",372 " end",373 ""]374 self.setOrigin(origin)375 self.setCursorPosition(1, 18)376 self.enter()377 self.type("end")378 self.verifyExpected(expected)379 def test_do6(self):380 origin = [381 "def foo(f)",382 " f.each do # loop",383 ""]384 expected = [385 "def foo(f)",386 " f.each do # loop",387 " bar",388 " end",389 ""]390 self.setOrigin(origin)391 self.setCursorPosition(1, 18)392 self.enter()393 self.type("bar")394 self.enter()395 self.type("end")396 self.verifyExpected(expected)397 def test_do7(self):398 origin = [399 "def foo(f)",400 " f.each do # loop with do",401 ""]402 expected = [403 "def foo(f)",404 " f.each do # loop with do",405 " bar",406 " end",407 ""]408 self.setOrigin(origin)409 self.setCursorPosition(1, 26)410 self.enter()411 self.type("bar")412 self.enter()413 self.type("end")414 self.verifyExpected(expected)415class NoDo(BaseTestClass):416 def test_no_do1(self):417 origin = [418 "# no-do1.txt",419 "if foo",420 " # nothing to do",421 ""]422 expected = [423 "# no-do1.txt",424 "if foo",425 " # nothing to do",426 "end",427 ""]428 self.setOrigin(origin)429 self.setCursorPosition(2, 32)430 self.enter()431 self.type("end")432 self.verifyExpected(expected)433 def test_no_do2(self):434 origin = [435 "# no-do2.txt",436 "if foo",437 " # nothing to do",438 ""]439 expected = [440 "# no-do2.txt",441 "if foo",442 " # nothing to do",443 " f",444 "end",445 ""]446 self.setOrigin(origin)447 self.setCursorPosition(2, 32)448 self.enter()449 self.type("f")450 self.enter()451 self.type("end")452 self.verifyExpected(expected)453 def test_no_do3(self):454 origin = [455 "# no-do3.txt",456 "if foo",457 ' puts "nothing" # nothing to do',458 ""]459 expected = [460 "# no-do3.txt",461 "if foo",462 ' puts "nothing" # nothing to do',463 "end",464 ""]465 self.setOrigin(origin)466 self.setCursorPosition(2, 32)467 self.enter()468 self.type("end")469 self.verifyExpected(expected)470 def test_no_do4(self):471 origin = [472 "# no-do4.txt",473 "if foo",474 ' puts "nothing" # nothing to do',475 ""]476 expected = [477 "# no-do4.txt",478 "if foo",479 ' puts "nothing" # nothing to do',480 " f",481 "end",482 ""]483 self.setOrigin(origin)484 self.setCursorPosition(2, 32)485 self.enter()486 self.type("f")487 self.enter()488 self.type("end")489 self.verifyExpected(expected)490class SingleLine(BaseTestClass):491 def test_singleline01(self):492 origin = [493 " def foo() 42 end",494 ""]495 expected = [496 " def foo() 42 end",497 " blah",498 ""]499 self.setOrigin(origin)500 self.setCursorPosition(0, 18)501 self.enter()502 self.type("blah")503 self.verifyExpected(expected)504 def test_singleline02(self):505 origin = [506 " def foo; 42 end",507 ""]508 expected = [509 " def foo; 42 end",510 " blah",511 ""]512 self.setOrigin(origin)513 self.setCursorPosition(0, 17)514 self.enter()515 self.type("blah")516 self.verifyExpected(expected)517 def test_singleline03(self):518 origin = [519 " def foo() bar",520 ""]521 expected = [522 " def foo() bar",523 " blah",524 ""]525 self.setOrigin(origin)526 self.setCursorPosition(0, 15)527 self.enter()528 self.type("blah")529 self.verifyExpected(expected)530 def test_singleline04(self):531 origin = [532 " def foo; bar",533 " blah",534 ""]535 expected = [536 " def foo; bar",537 " blah",538 " end",539 ""]540 self.setOrigin(origin)541 self.setCursorPosition(1, 8)542 self.enter()543 self.type("end")544 self.verifyExpected(expected)545class Array(BaseTestClass):546 def test_array1(self):547 origin = [548 " array = [ :a, :b, :c ]",549 ""]550 expected = [551 " array = [ :a, :b, :c ]",552 " foo",553 ""]554 self.setOrigin(origin)555 self.setCursorPosition(0, 24)556 self.enter()557 self.type("foo")558 self.verifyExpected(expected)559 def test_array2(self):560 origin = [561 " array = [",562 ""]563 expected = [564 " array = [",565 " :a",566 ""]567 self.setOrigin(origin)568 self.setCursorPosition(0, 11)569 self.enter()570 self.type(":a")571 self.verifyExpected(expected)572 def test_array3(self):573 origin = [574 " array = [",575 " :a,",576 ""]577 expected = [578 " array = [",579 " :a,",580 " :b",581 ""]582 self.setOrigin(origin)583 self.setCursorPosition(1, 7)584 self.enter()585 self.type(":b")586 self.verifyExpected(expected)587 def test_array4(self):588 origin = [589 " array = [",590 " :a,",591 " :b",592 ""]593 expected = [594 " array = [",595 " :a,",596 " :b",597 " ]",598 ""]599 self.setOrigin(origin)600 self.setCursorPosition(2, 6)601 self.enter()602 self.type("]")603 self.verifyExpected(expected)604 def test_array5(self):605 origin = [606 " array = [",607 " :a,",608 " :b",609 ""]610 expected = [611 " array = [",612 " :a,",613 " :b",614 " (3,2)",615 "",616 ""]617 self.setOrigin(origin)618 self.setCursorPosition(2, 6)619 self.enter()620 self.writeCursorPosition()621 self.writeln()622 self.verifyExpected(expected)623 def test_array6(self):624 origin = [625 " array = [:a,",626 " :b,",627 " :c]",628 ""]629 expected = [630 " array = [:a,",631 " :b,",632 " :c]",633 " foo",634 ""]635 self.setOrigin(origin)636 self.setCursorPosition(2, 14)637 self.enter()638 self.type("foo")639 self.verifyExpected(expected)640 def test_array7(self):641 origin = [642 " array = [:a,",643 ""]644 expected = [645 " array = [:a,",646 " :b",647 ""]648 self.setOrigin(origin)649 self.setCursorPosition(0, 14)650 self.enter()651 self.type(":b")652 self.verifyExpected(expected)653 def test_array8(self):654 origin = [655 " array = [:a,",656 " :b,",657 ""]658 expected = [659 " array = [:a,",660 " :b,",661 " :c",662 ""]663 self.setOrigin(origin)664 self.setCursorPosition(1, 14)665 self.enter()666 self.type(":c")667 self.verifyExpected(expected)668 def test_array9(self):669 origin = [670 " array = [:a,",671 " :b,",672 " :c",673 ""]674 expected = [675 " array = [:a,",676 " :b,",677 " :c]",678 " foo",679 ""]680 self.setOrigin(origin)681 self.setCursorPosition(2, 13)682 self.type("]")683 self.enter()684 self.type("foo")685 self.verifyExpected(expected)686 def test_array10(self):687 origin = [688 " array = [:a,",689 " :b,",690 " [:foo,",691 ""]692 expected = [693 " array = [:a,",694 " :b,",695 " [:foo,",696 " :bar",697 ""]698 self.setOrigin(origin)699 self.setCursorPosition(2, 17)700 self.enter()701 self.type(":bar")702 self.verifyExpected(expected)703 def test_array11(self):704 origin = [705 " array = [:a,",706 " :b,",707 " [:foo,",708 " :bar,",709 ""]710 expected = [711 " array = [:a,",712 " :b,",713 " [:foo,",714 " :bar,",715 " :baz",716 ""]717 self.setOrigin(origin)718 self.setCursorPosition(3, 17)719 self.enter()720 self.type(":baz")721 self.verifyExpected(expected)722 def test_array12(self):723 origin = [724 " array = [:a,",725 " :b,",726 " [:foo,",727 " :bar],",728 ""]729 expected = [730 " array = [:a,",731 " :b,",732 " [:foo,",733 " :bar],",734 " :baz",735 ""]736 self.setOrigin(origin)737 self.setCursorPosition(3, 18)738 self.enter()739 self.type(":baz")740 self.verifyExpected(expected)741 def test_array16(self):742 origin = [743 " array = [ :a,",744 " :b,",745 " :c ]",746 ""]747 expected = [748 " array = [ :a,",749 " :b,",750 " :c ]",751 " foo",752 ""]753 self.setOrigin(origin)754 self.setCursorPosition(2, 16)755 self.enter()756 self.type("foo")757 self.verifyExpected(expected)758 def test_array17(self):759 origin = [760 " array = [ :a,",761 ""]762 expected = [763 " array = [ :a,",764 " :b",765 ""]766 self.setOrigin(origin)767 self.setCursorPosition(0, 15)768 self.enter()769 self.type(":b")770 self.verifyExpected(expected)771 def test_array18(self):772 origin = [773 " array = [ :a,",774 " :b,",775 ""]776 expected = [777 " array = [ :a,",778 " :b,",779 " :c",780 ""]781 self.setOrigin(origin)782 self.setCursorPosition(1, 15)783 self.enter()784 self.type(":c")785 self.verifyExpected(expected)786 def test_array19(self):787 origin = [788 " array = [ :a,",789 " :b,",790 " :c",791 ""]792 expected = [793 " array = [ :a,",794 " :b,",795 " :c ]",796 " foo",797 ""]798 self.setOrigin(origin)799 self.setCursorPosition(2, 14)800 self.type(" ]")801 self.enter()802 self.type("foo")803 self.verifyExpected(expected)804 def test_array20(self):805 origin = [806 " array = [ :a,",807 " :b,",808 " [ :foo,",809 ""]810 expected = [811 " array = [ :a,",812 " :b,",813 " [ :foo,",814 " :bar",815 ""]816 self.setOrigin(origin)817 self.setCursorPosition(2, 19)818 self.enter()819 self.type(":bar")820 self.verifyExpected(expected)821 def test_array21(self):822 origin = [823 " array = [ :a,",824 " :b,",825 " [ :foo,",826 " :bar,",827 ""]828 expected = [829 " array = [ :a,",830 " :b,",831 " [ :foo,",832 " :bar,",833 " :baz",834 ""]835 self.setOrigin(origin)836 self.setCursorPosition(3, 19)837 self.enter()838 self.type(":baz")839 self.verifyExpected(expected)840 def test_array22(self):841 origin = [842 " array = [ :a,",843 " :b,",844 " [ :foo,",845 " :bar ],",846 ""]847 expected = [848 " array = [ :a,",849 " :b,",850 " [ :foo,",851 " :bar ],",852 " :baz",853 ""]854 self.setOrigin(origin)855 self.setCursorPosition(3, 21)856 self.enter()857 self.type(":baz")858 self.verifyExpected(expected)859class ArrayComment(BaseTestClass):860 def test_array_comment1(self):861 origin = [862 " array = [ :a, :b, :c ] # comment",863 " # comment",864 ""]865 expected = [866 " array = [ :a, :b, :c ] # comment",867 " # comment",868 " foo",869 ""]870 self.setOrigin(origin)871 self.setCursorPosition(1, 34)872 self.enter()873 self.type("foo")874 self.verifyExpected(expected)875 def test_array_comment2(self):876 origin = [877 " array = [ # comment",878 ""]879 expected = [880 " array = [ # comment",881 " :a",882 ""]883 self.setOrigin(origin)884 self.setCursorPosition(0, 21)885 self.enter()886 self.type(":a")887 self.verifyExpected(expected)888 def test_array_comment3(self):889 origin = [890 " array = [ # comment",891 " :a, # comment",892 ""]893 expected = [894 " array = [ # comment",895 " :a, # comment",896 " :b",897 ""]898 self.setOrigin(origin)899 self.setCursorPosition(1, 21)900 self.enter()901 self.type(":b")902 self.verifyExpected(expected)903 def test_array_comment4(self):904 origin = [905 " array = [",906 " :a,",907 " :b # comment,",908 ""]909 expected = [910 " array = [",911 " :a,",912 " :b # comment,",913 " ]",914 ""]915 self.setOrigin(origin)916 self.setCursorPosition(2, 17)917 self.enter()918 self.type("]")919 self.verifyExpected(expected)920 def test_array_comment5(self):921 origin = [922 " array = [",923 " :a,",924 " :b # comment",925 ""]926 expected = [927 " array = [",928 " :a,",929 " :b # comment",930 " (3,2)",931 "",932 ""]933 self.setOrigin(origin)934 self.setCursorPosition(2, 16)935 self.enter()936 self.writeCursorPosition()937 self.writeln()938 self.verifyExpected(expected)939class Hash(BaseTestClass):940 def test_hash1(self):941 origin = [942 " hash = { :a => 1, :b => 2, :c => 3 }",943 ""]944 expected = [945 " hash = { :a => 1, :b => 2, :c => 3 }",946 " foo",947 ""]948 self.setOrigin(origin)949 self.setCursorPosition(0, 38)950 self.enter()951 self.type("foo")952 self.verifyExpected(expected)953 def test_hash2(self):954 origin = [955 " hash = {",956 ""]957 expected = [958 " hash = {",959 " :a => 1",960 ""]961 self.setOrigin(origin)962 self.setCursorPosition(0, 10)963 self.enter()964 self.type(":a => 1")965 self.verifyExpected(expected)966 def test_hash3(self):967 origin = [968 " hash = {",969 " :a => 1,",970 ""]971 expected = [972 " hash = {",973 " :a => 1,",974 " :b => 2",975 ""]976 self.setOrigin(origin)977 self.setCursorPosition(1, 12)978 self.enter()979 self.type(":b => 2")980 self.verifyExpected(expected)981 def test_hash4(self):982 origin = [983 " hash = {",984 " :a => 1,",985 " :b => 2",986 ""]987 expected = [988 " hash = {",989 " :a => 1,",990 " :b => 2",991 " }",992 ""]993 self.setOrigin(origin)994 self.setCursorPosition(2, 11)995 self.enter()996 self.type("}")997 self.verifyExpected(expected)998 def test_hash5(self):999 origin = [1000 " hash = {",1001 " :a => 1,",1002 " :b => 2",1003 ""]1004 expected = [1005 " hash = {",1006 " :a => 1,",1007 " :b => 2",1008 " (3,2)",1009 "",1010 ""]1011 self.setOrigin(origin)1012 self.setCursorPosition(2, 11)1013 self.enter()1014 self.writeCursorPosition()1015 self.writeln()1016 self.verifyExpected(expected)1017 def test_hash6(self):1018 origin = [1019 " hash = {:a => 1,",1020 " :b => 2,",1021 " :c => 3}",1022 ""]1023 expected = [1024 " hash = {:a => 1,",1025 " :b => 2,",1026 " :c => 3}",1027 " foo",1028 ""]1029 self.setOrigin(origin)1030 self.setCursorPosition(2, 18)1031 self.enter()1032 self.type("foo")1033 self.verifyExpected(expected)1034 def test_hash7(self):1035 origin = [1036 " hash = {:a => 1,",1037 ""]1038 expected = [1039 " hash = {:a => 1,",1040 " :b => 2",1041 ""]1042 self.setOrigin(origin)1043 self.setCursorPosition(0, 18)1044 self.enter()1045 self.type(":b => 2")1046 self.verifyExpected(expected)1047 def test_hash8(self):1048 origin = [1049 " hash = {:a => 1,",1050 " :b => 2,",1051 ""]1052 expected = [1053 " hash = {:a => 1,",1054 " :b => 2,",1055 " :c => 3",1056 ""]1057 self.setOrigin(origin)1058 self.setCursorPosition(1, 18)1059 self.enter()1060 self.type(":c => 3")1061 self.verifyExpected(expected)1062 def test_hash9(self):1063 origin = [1064 " hash = {:a => 1,",1065 " :b => 2,",1066 " :c => 3",1067 ""]1068 expected = [1069 " hash = {:a => 1,",1070 " :b => 2,",1071 " :c => 3}",1072 " foo",1073 ""]1074 self.setOrigin(origin)1075 self.setCursorPosition(2, 17)1076 self.type("}")1077 self.enter()1078 self.type("foo")1079 self.verifyExpected(expected)1080 def test_hash10(self):1081 origin = [1082 " hash = {:a => 1,",1083 " :b => 2,",1084 " :c => {:foo => /^f/,",1085 ""]1086 expected = [1087 " hash = {:a => 1,",1088 " :b => 2,",1089 " :c => {:foo => /^f/,",1090 " :bar => /^b/",1091 ""]1092 self.setOrigin(origin)1093 self.setCursorPosition(2, 30)1094 self.enter()1095 self.type(":bar => /^b/")1096 self.verifyExpected(expected)1097 def test_hash11(self):1098 origin = [1099 " hash = {:a => 1,",1100 " :b => 2,",1101 " :c => {:foo => /^f/,",1102 " :bar => /^b/},",1103 ""]1104 expected = [1105 " hash = {:a => 1,",1106 " :b => 2,",1107 " :c => {:foo => /^f/,",1108 " :bar => /^b/},",1109 " :d => 4",1110 ""]1111 self.setOrigin(origin)1112 self.setCursorPosition(3, 31)1113 self.enter()1114 self.type(":d => 4")1115 self.verifyExpected(expected)1116 def test_hash12(self):1117 origin = [1118 " hash = {:a => 1,",1119 " :b => 2,",1120 " :c => {:foo => /^f/,",1121 " :bar => /^b/,",1122 ""]1123 expected = [1124 " hash = {:a => 1,",1125 " :b => 2,",1126 " :c => {:foo => /^f/,",1127 " :bar => /^b/,",1128 " :baz => /^b/",1129 ""]1130 self.setOrigin(origin)1131 self.setCursorPosition(3, 30)1132 self.enter()1133 self.type(":baz => /^b/")1134 self.verifyExpected(expected)1135 def test_hash16(self):1136 origin = [1137 " hash = { :a => 1,",1138 " :b => 2,",1139 " :c => 3 }",1140 ""]1141 expected = [1142 " hash = { :a => 1,",1143 " :b => 2,",1144 " :c => 3 }",1145 " foo",1146 ""]1147 self.setOrigin(origin)1148 self.setCursorPosition(2, 20)1149 self.enter()1150 self.type("foo")1151 self.verifyExpected(expected)1152 def test_hash17(self):1153 origin = [1154 " hash = { :a => 1,",1155 ""]1156 expected = [1157 " hash = { :a => 1,",1158 " :b => 2",1159 ""]1160 self.setOrigin(origin)1161 self.setCursorPosition(0, 19)1162 self.enter()1163 self.type(":b => 2")1164 self.verifyExpected(expected)1165 def test_hash18(self):1166 origin = [1167 " hash = { :a => 1,",1168 " :b => 2,",1169 ""]1170 expected = [1171 " hash = { :a => 1,",1172 " :b => 2,",1173 " :c => 3",1174 ""]1175 self.setOrigin(origin)1176 self.setCursorPosition(1, 19)1177 self.enter()1178 self.type(":c => 3")1179 self.verifyExpected(expected)1180 def test_hash19(self):1181 origin = [1182 " hash = { :a => 1,",1183 " :b => 2,",1184 " :c => 3",1185 ""]1186 expected = [1187 " hash = { :a => 1,",1188 " :b => 2,",1189 " :c => 3 }",1190 " foo",1191 ""]1192 self.setOrigin(origin)1193 self.setCursorPosition(2, 18)1194 self.type(" }")1195 self.enter()1196 self.type("foo")1197 self.verifyExpected(expected)1198 def test_hash20(self):1199 origin = [1200 " hash = { :a => 1,",1201 " :b => 2,",1202 " :c => { :foo => /^f/,",1203 ""]1204 expected = [1205 " hash = { :a => 1,",1206 " :b => 2,",1207 " :c => { :foo => /^f/,",1208 " :bar => /^b/",1209 ""]1210 self.setOrigin(origin)1211 self.setCursorPosition(2, 32)1212 self.enter()1213 self.type(":bar => /^b/")1214 self.verifyExpected(expected)1215 def test_hash21(self):1216 origin = [1217 " hash = { :a => 1,",1218 " :b => 2,",1219 " :c => { :foo => /^f/,",1220 " :bar => /^b/ },",1221 ""]1222 expected = [1223 " hash = { :a => 1,",1224 " :b => 2,",1225 " :c => { :foo => /^f/,",1226 " :bar => /^b/ },",1227 " :d => 4",1228 ""]1229 self.setOrigin(origin)1230 self.setCursorPosition(3, 34)1231 self.enter()1232 self.type(":d => 4")1233 self.verifyExpected(expected)1234 def test_hash22(self):1235 origin = [1236 " hash = { :a => 1,",1237 " :b => 2,",1238 " :c => { :foo => /^f/,",1239 " :bar => /^b/,",1240 ""]1241 expected = [1242 " hash = { :a => 1,",1243 " :b => 2,",1244 " :c => { :foo => /^f/,",1245 " :bar => /^b/,",1246 " :baz => /^b/",1247 ""]1248 self.setOrigin(origin)1249 self.setCursorPosition(3, 32)1250 self.enter()1251 self.type(":baz => /^b/")1252 self.verifyExpected(expected)1253class Ops(BaseTestClass):1254 def test_ops1(self):1255 origin = [1256 "t = foo() +",1257 ""]1258 expected = [1259 "t = foo() +",1260 " bar()",1261 ""]1262 self.setOrigin(origin)1263 self.setCursorPosition(0, 11)1264 self.enter()1265 self.type("bar()")1266 self.verifyExpected(expected)1267 def test_ops2(self):1268 origin = [1269 "t = foo() + # Comment",1270 ""]1271 expected = [1272 "t = foo() + # Comment",1273 " bar()",1274 ""]1275 self.setOrigin(origin)1276 self.setCursorPosition(0, 21)1277 self.enter()1278 self.type("bar()")1279 self.verifyExpected(expected)1280 def test_ops3(self):1281 origin = [1282 "t = foo() -",1283 ""]1284 expected = [1285 "t = foo() -",1286 " bar()",1287 ""]1288 self.setOrigin(origin)1289 self.setCursorPosition(0, 11)1290 self.enter()1291 self.type("bar()")1292 self.verifyExpected(expected)1293 def test_ops4(self):1294 origin = [1295 "t = foo() - # Comment",1296 ""]1297 expected = [1298 "t = foo() - # Comment",1299 " bar()",1300 ""]1301 self.setOrigin(origin)1302 self.setCursorPosition(0, 21)1303 self.enter()1304 self.type("bar()")1305 self.verifyExpected(expected)1306 def test_ops5(self):1307 origin = [1308 "t = foo() *",1309 ""]1310 expected = [1311 "t = foo() *",1312 " bar()",1313 ""]1314 self.setOrigin(origin)1315 self.setCursorPosition(0, 11)1316 self.enter()1317 self.type("bar()")1318 self.verifyExpected(expected)1319 def test_ops6(self):1320 origin = [1321 "t = foo() * # Comment",1322 ""]1323 expected = [1324 "t = foo() * # Comment",1325 " bar()",1326 ""]1327 self.setOrigin(origin)1328 self.setCursorPosition(0, 21)1329 self.enter()1330 self.type("bar()")1331 self.verifyExpected(expected)1332 def test_ops7(self):1333 origin = [1334 "t = foo() /",1335 ""]1336 expected = [1337 "t = foo() /",1338 " bar()",1339 ""]1340 self.setOrigin(origin)1341 self.setCursorPosition(0, 11)1342 self.enter()1343 self.type("bar()")1344 self.verifyExpected(expected)1345 def test_ops8(self):1346 origin = [1347 "t = foo() / # Comment",1348 ""]1349 expected = [1350 "t = foo() / # Comment",1351 " bar()",1352 ""]1353 self.setOrigin(origin)1354 self.setCursorPosition(0, 21)1355 self.enter()1356 self.type("bar()")1357 self.verifyExpected(expected)1358 def test_ops11(self):1359 origin = [1360 "t = foo() +",1361 " bar()",1362 ""]1363 expected = [1364 "t = foo() +",1365 " bar()",1366 "foobar",1367 ""]1368 self.setOrigin(origin)1369 self.setCursorPosition(1, 9)1370 self.enter()1371 self.type("foobar")1372 self.verifyExpected(expected)1373 def test_ops12(self):1374 origin = [1375 "t = foo() + # Comment",1376 " bar()",1377 ""]1378 expected = [1379 "t = foo() + # Comment",1380 " bar()",1381 "foobar",1382 ""]1383 self.setOrigin(origin)1384 self.setCursorPosition(1, 9)1385 self.enter()1386 self.type("foobar")1387 self.verifyExpected(expected)1388 def test_ops13(self):1389 origin = [1390 "t = foo() -",1391 " bar()",1392 ""]1393 expected = [1394 "t = foo() -",1395 " bar()",1396 "foobar",1397 ""]1398 self.setOrigin(origin)1399 self.setCursorPosition(1, 9)1400 self.enter()1401 self.type("foobar")1402 self.verifyExpected(expected)1403 def test_ops14(self):1404 origin = [1405 "t = foo() - # Comment",1406 " bar()",1407 ""]1408 expected = [1409 "t = foo() - # Comment",1410 " bar()",1411 "foobar",1412 ""]1413 self.setOrigin(origin)1414 self.setCursorPosition(1, 9)1415 self.enter()1416 self.type("foobar")1417 self.verifyExpected(expected)1418 def test_ops15(self):1419 origin = [1420 "t = foo() *",1421 " bar()",1422 ""]1423 expected = [1424 "t = foo() *",1425 " bar()",1426 "foobar",1427 ""]1428 self.setOrigin(origin)1429 self.setCursorPosition(1, 9)1430 self.enter()1431 self.type("foobar")1432 self.verifyExpected(expected)1433 def test_ops16(self):1434 origin = [1435 "t = foo() * # Comment",1436 " bar()",1437 ""]1438 expected = [1439 "t = foo() * # Comment",1440 " bar()",1441 "foobar",1442 ""]1443 self.setOrigin(origin)1444 self.setCursorPosition(1, 9)1445 self.enter()1446 self.type("foobar")1447 self.verifyExpected(expected)1448 def test_ops17(self):1449 origin = [1450 "t = foo() /",1451 " bar()",1452 ""]1453 expected = [1454 "t = foo() /",1455 " bar()",1456 "foobar",1457 ""]1458 self.setOrigin(origin)1459 self.setCursorPosition(1, 9)1460 self.enter()1461 self.type("foobar")1462 self.verifyExpected(expected)1463 def test_ops18(self):1464 origin = [1465 "t = foo() / # Comment",1466 " bar()",1467 ""]1468 expected = [1469 "t = foo() / # Comment",1470 " bar()",1471 "foobar",1472 ""]1473 self.setOrigin(origin)1474 self.setCursorPosition(1, 9)1475 self.enter()1476 self.type("foobar")1477 self.verifyExpected(expected)1478 def test_ops21(self):1479 origin = [1480 "t = foo() +",1481 " bar() # Comment",1482 ""]1483 expected = [1484 "t = foo() +",1485 " bar() # Comment",1486 "foobar",1487 ""]1488 self.setOrigin(origin)1489 self.setCursorPosition(1, 19)1490 self.enter()1491 self.type("foobar")1492 self.verifyExpected(expected)1493 def test_ops22(self):1494 origin = [1495 "t = foo() + # Comment",1496 " bar() # Comment",1497 ""]1498 expected = [1499 "t = foo() + # Comment",1500 " bar() # Comment",1501 "foobar",1502 ""]1503 self.setOrigin(origin)1504 self.setCursorPosition(1, 19)1505 self.enter()1506 self.type("foobar")1507 self.verifyExpected(expected)1508 def test_ops23(self):1509 origin = [1510 "t = foo() -",1511 " bar() # Comment",1512 ""]1513 expected = [1514 "t = foo() -",1515 " bar() # Comment",1516 "foobar",1517 ""]1518 self.setOrigin(origin)1519 self.setCursorPosition(1, 19)1520 self.enter()1521 self.type("foobar")1522 self.verifyExpected(expected)1523 def test_ops24(self):1524 origin = [1525 "t = foo() - # Comment",1526 " bar() # Comment",1527 ""]1528 expected = [1529 "t = foo() - # Comment",1530 " bar() # Comment",1531 "foobar",1532 ""]1533 self.setOrigin(origin)1534 self.setCursorPosition(1, 19)1535 self.enter()1536 self.type("foobar")1537 self.verifyExpected(expected)1538 def test_ops25(self):1539 origin = [1540 "t = foo() *",1541 " bar() # Comment",1542 ""]1543 expected = [1544 "t = foo() *",1545 " bar() # Comment",1546 "foobar",1547 ""]1548 self.setOrigin(origin)1549 self.setCursorPosition(1, 19)1550 self.enter()1551 self.type("foobar")1552 self.verifyExpected(expected)1553 def test_ops26(self):1554 origin = [1555 "t = foo() * # Comment",1556 " bar() # Comment",1557 ""]1558 expected = [1559 "t = foo() * # Comment",1560 " bar() # Comment",1561 "foobar",1562 ""]1563 self.setOrigin(origin)1564 self.setCursorPosition(1, 19)1565 self.enter()1566 self.type("foobar")1567 self.verifyExpected(expected)1568 def test_ops27(self):1569 origin = [1570 "t = foo() /",1571 " bar() # Comment",1572 ""]1573 expected = [1574 "t = foo() /",1575 " bar() # Comment",1576 "foobar",1577 ""]1578 self.setOrigin(origin)1579 self.setCursorPosition(1, 19)1580 self.enter()1581 self.type("foobar")1582 self.verifyExpected(expected)1583 def test_ops28(self):1584 origin = [1585 "t = foo() / # Comment",1586 " bar() # Comment",1587 ""]1588 expected = [1589 "t = foo() / # Comment",1590 " bar() # Comment",1591 "foobar",1592 ""]1593 self.setOrigin(origin)1594 self.setCursorPosition(1, 19)1595 self.enter()1596 self.type("foobar")1597 self.verifyExpected(expected)1598class WordList(BaseTestClass):1599 def test_wordlist01(self):1600 origin = [1601 " for elem in %w[ foo, bar,",1602 ""]1603 expected = [1604 " for elem in %w[ foo, bar,",1605 " foobar",1606 ""]1607 self.setOrigin(origin)1608 self.setCursorPosition(0, 27)1609 self.enter()1610 self.type("foobar")1611 self.verifyExpected(expected)1612 def test_wordlist02(self):1613 origin = [1614 " for elem in %w[ foo, bar,",1615 " foobar ]",1616 ""]1617 expected = [1618 " for elem in %w[ foo, bar,",1619 " foobar ]",1620 " blah",1621 ""]1622 self.setOrigin(origin)1623 self.setCursorPosition(1, 26)1624 self.enter()1625 self.type("blah")1626 self.verifyExpected(expected)1627 @unittest.expectedFailure1628 def test_wordlist11(self):1629 origin = [1630 " for elem in %w< foo, bar,",1631 ""]1632 expected = [1633 " for elem in %w< foo, bar,",1634 " foobar",1635 ""]1636 self.setOrigin(origin)1637 self.setCursorPosition(0, 27)1638 self.enter()1639 self.type("foobar")1640 self.verifyExpected(expected)1641 @unittest.expectedFailure # failed by kate1642 def test_wordlist12(self):1643 origin = [1644 " for elem in %w< foo, bar,",1645 " foobar >",1646 ""]1647 expected = [1648 " for elem in %w< foo, bar,",1649 " foobar >",1650 " blah",1651 ""]1652 self.setOrigin(origin)1653 self.setCursorPosition(1, 26)1654 self.enter()1655 self.type("blah")1656 self.verifyExpected(expected)1657 @unittest.expectedFailure1658 def test_wordlist21(self):1659 origin = [1660 " for elem in %w| foo, bar,",1661 ""]1662 expected = [1663 " for elem in %w| foo, bar,",1664 " foobar",1665 ""]1666 self.setOrigin(origin)1667 self.setCursorPosition(0, 27)1668 self.enter()1669 self.type("foobar")1670 self.verifyExpected(expected)1671 @unittest.expectedFailure # failed by kate1672 def test_wordlist22(self):1673 origin = [1674 " for elem in %w| foo, bar,",1675 " foobar |",1676 ""]1677 expected = [1678 " for elem in %w| foo, bar,",1679 " foobar |",1680 " blah",1681 ""]1682 self.setOrigin(origin)1683 self.setCursorPosition(1, 26)1684 self.enter()1685 self.type("blah")1686 self.verifyExpected(expected)1687class Multiline(BaseTestClass):1688 def test_multiline1(self):1689 origin = [1690 "# multiline1.txt",1691 'if (foo == "bar" and',1692 ' bar == "foo")',1693 ""]1694 expected = [1695 "# multiline1.txt",1696 'if (foo == "bar" and',1697 ' bar == "foo")',1698 "end",1699 ""]1700 self.setOrigin(origin)1701 self.setCursorPosition(2, 17)1702 self.enter()1703 self.type("end")1704 self.verifyExpected(expected)1705 def test_multiline2(self):1706 origin = [1707 "# multiline2.txt",1708 'if (foo == "bar" and',1709 ' bar == "foo")',1710 ""]1711 expected = [1712 "# multiline2.txt",1713 'if (foo == "bar" and',1714 ' bar == "foo")',1715 " puts",1716 "end",1717 ""]1718 self.setOrigin(origin)1719 self.setCursorPosition(2, 17)1720 self.enter()1721 self.type("puts")1722 self.enter()1723 self.type("end")1724 self.verifyExpected(expected)1725 def test_multiline3(self):1726 origin = [1727 "# multiline3.txt",1728 's = "hello" +',1729 ""]1730 expected = [1731 "# multiline3.txt",1732 's = "hello" +',1733 ' "world"',1734 "bar",1735 ""]1736 self.setOrigin(origin)1737 self.setCursorPosition(1, 15)1738 self.enter()1739 self.type("\"world\"")1740 self.enter()1741 self.type("bar")1742 self.verifyExpected(expected)1743 def test_multiline4(self):1744 origin = [1745 "# multiline4.txt",1746 's = "hello" +',1747 " # Comment",1748 ""]1749 expected = [1750 "# multiline4.txt",1751 's = "hello" +',1752 " # Comment",1753 ' "world"',1754 "bar",1755 ""]1756 self.setOrigin(origin)1757 self.setCursorPosition(2, 19)1758 self.enter()1759 self.type("\"world\"")1760 self.enter()1761 self.type("bar")1762 self.verifyExpected(expected)1763 def test_multiline5(self):1764 origin = [1765 "# multiline5.txt",1766 's = "hello" +',1767 "# Misplaced comment",1768 ""]1769 expected = [1770 "# multiline5.txt",1771 's = "hello" +',1772 "# Misplaced comment",1773 ' "world"',1774 "bar",1775 ""]1776 self.setOrigin(origin)1777 self.setCursorPosition(2, 19)1778 self.enter()1779 self.type("\"world\"")1780 self.enter()1781 self.type("bar")1782 self.verifyExpected(expected)1783 @unittest.expectedFailure1784 def test_multiline6(self):1785 origin = [1786 "# multiline6.txt",1787 'foo "hello" \\',1788 ""]1789 expected = [1790 "# multiline6.txt",1791 'foo "hello" \\',1792 "",1793 "bar",1794 ""]1795 self.setOrigin(origin)1796 self.setCursorPosition(1, 13)1797 self.enter()1798 self.enter()1799 self.type("bar")1800 self.verifyExpected(expected)1801 def test_multiline7(self):1802 origin = [1803 'foo "hello",',1804 ""]1805 expected = [1806 'foo "hello",',1807 ' "world"',1808 ""]1809 self.setOrigin(origin)1810 self.setCursorPosition(0, 13)1811 self.enter()1812 self.type("\"world\"")1813 self.verifyExpected(expected)1814 def test_multiline8(self):1815 origin = [1816 "def foo(array)",1817 " array.each_with_index \\",1818 " do",1819 ""]1820 expected = [1821 "def foo(array)",1822 " array.each_with_index \\",1823 " do",1824 " bar",1825 " end",1826 ""]1827 self.setOrigin(origin)1828 self.setCursorPosition(2, 8)1829 self.enter()1830 self.type("bar")1831 self.enter()1832 self.type("end")1833 self.verifyExpected(expected)1834 def test_multiline9(self):1835 origin = [1836 "if test \\",1837 '# if ends here',1838 ' foo do',1839 ""]1840 expected = [1841 "if test \\",1842 '# if ends here',1843 ' foo do',1844 " bar",1845 ""]1846 self.setOrigin(origin)1847 self.setCursorPosition(2, 8)1848 self.enter()1849 self.type("bar")1850 self.verifyExpected(expected)1851 def test_multiline10(self):1852 origin = [1853 "if test1 &&",1854 "# still part of condition",1855 " test2",1856 ""]1857 expected = [1858 "if test1 &&",1859 "# still part of condition",1860 " test2",1861 " foo",1862 ""]1863 self.setOrigin(origin)1864 self.setCursorPosition(2, 8)1865 self.enter()1866 self.type("foo")1867 self.verifyExpected(expected)1868class Plist(BaseTestClass):1869 def test_plist1(self):1870 origin = [1871 " foobar(foo,",1872 ""]1873 expected = [1874 " foobar(foo,",1875 " bar",1876 ""]1877 self.setOrigin(origin)1878 self.setCursorPosition(0, 13)1879 self.enter()1880 self.type("bar")1881 self.verifyExpected(expected)1882 def test_plist2(self):1883 origin = [1884 " foobar(foo, foo,",1885 ""]1886 expected = [1887 " foobar(foo, foo,",1888 " bar",1889 ""]1890 self.setOrigin(origin)1891 self.setCursorPosition(0, 18)1892 self.enter()1893 self.type("bar")1894 self.verifyExpected(expected)1895 def test_plist3(self):1896 origin = [1897 " foobar(foo,",1898 " bar)",1899 ""]1900 expected = [1901 " foobar(foo,",1902 " bar)",1903 " blah",1904 ""]1905 self.setOrigin(origin)1906 self.setCursorPosition(1, 13)1907 self.enter()1908 self.type("blah")1909 self.verifyExpected(expected)1910 def test_plist4(self):1911 origin = [1912 " foobar(foo,",1913 " bar,",1914 ""]1915 expected = [1916 " foobar(foo,",1917 " bar,",1918 " baz",1919 ""]1920 self.setOrigin(origin)1921 self.setCursorPosition(1, 13)1922 self.enter()1923 self.type("baz")1924 self.verifyExpected(expected)1925 def test_plist5(self):1926 origin = [1927 " foobar(foo,",1928 " bar, bar,",1929 ""]1930 expected = [1931 " foobar(foo,",1932 " bar, bar,",1933 " baz",1934 ""]1935 self.setOrigin(origin)1936 self.setCursorPosition(1, 18)1937 self.enter()1938 self.type("baz")1939 self.verifyExpected(expected)1940 def test_plist6(self):1941 origin = [1942 " foobar(foo,",1943 " bar,",1944 " baz)",1945 ""]1946 expected = [1947 " foobar(foo,",1948 " bar,",1949 " baz)",1950 " blah",1951 ""]1952 self.setOrigin(origin)1953 self.setCursorPosition(2, 13)1954 self.enter()1955 self.type("blah")1956 self.verifyExpected(expected)1957 def test_plist7(self):1958 origin = [1959 " foobar(foo(bar,",1960 ""]1961 expected = [1962 " foobar(foo(bar,",1963 " baz",1964 ""]1965 self.setOrigin(origin)1966 self.setCursorPosition(0, 17)1967 self.enter()1968 self.type("baz")1969 self.verifyExpected(expected)1970 def test_plist8(self):1971 origin = [1972 " foobar(foo(bar,",1973 " baz),",1974 ""]1975 expected = [1976 " foobar(foo(bar,",1977 " baz),",1978 " blah",1979 ""]1980 self.setOrigin(origin)1981 self.setCursorPosition(1, 18)1982 self.enter()1983 self.type("blah")1984 self.verifyExpected(expected)1985 def test_plist9(self):1986 origin = [1987 " foobar(foo(bar,",1988 " baz),",1989 " foobaz(),",1990 ""]1991 expected = [1992 " foobar(foo(bar,",1993 " baz),",1994 " foobaz(),",1995 " blah",1996 ""]1997 self.setOrigin(origin)1998 self.setCursorPosition(2, 18)1999 self.enter()2000 self.type("blah")2001 self.verifyExpected(expected)2002 def test_plist10(self):2003 origin = [2004 " foobar(foo(bar,",2005 " baz),",2006 " blah)",2007 ""]2008 expected = [2009 " foobar(foo(bar,",2010 " baz),",2011 " blah)",2012 " foobaz",2013 ""]2014 self.setOrigin(origin)2015 self.setCursorPosition(2, 14)2016 self.enter()2017 self.type("foobaz")2018 self.verifyExpected(expected)2019 def test_plist11(self):2020 origin = [2021 " foobar( foo,",2022 ""]2023 expected = [2024 " foobar( foo,",2025 " bar",2026 ""]2027 self.setOrigin(origin)2028 self.setCursorPosition(0, 14)2029 self.enter()2030 self.type("bar")2031 self.verifyExpected(expected)2032 def test_plist12(self):2033 origin = [2034 " foobar( foo, foo,",2035 ""]2036 expected = [2037 " foobar( foo, foo,",2038 " bar",2039 ""]2040 self.setOrigin(origin)2041 self.setCursorPosition(0, 19)2042 self.enter()2043 self.type("bar")2044 self.verifyExpected(expected)2045 def test_plist13(self):2046 origin = [2047 " foobar( foo,",2048 " bar )",2049 ""]2050 expected = [2051 " foobar( foo,",2052 " bar )",2053 " blah",2054 ""]2055 self.setOrigin(origin)2056 self.setCursorPosition(1, 15)2057 self.enter()2058 self.type("blah")2059 self.verifyExpected(expected)2060 def test_plist14(self):2061 origin = [2062 " foobar ( foo,",2063 " bar,",2064 ""]2065 expected = [2066 " foobar ( foo,",2067 " bar,",2068 " baz",2069 ""]2070 self.setOrigin(origin)2071 self.setCursorPosition(1, 15)2072 self.enter()2073 self.type("baz")2074 self.verifyExpected(expected)2075 def test_plist15(self):2076 origin = [2077 " foobar ( foo,",2078 " bar, bar,",2079 ""]2080 expected = [2081 " foobar ( foo,",2082 " bar, bar,",2083 " baz",2084 ""]2085 self.setOrigin(origin)2086 self.setCursorPosition(1, 20)2087 self.enter()2088 self.type("baz")2089 self.verifyExpected(expected)2090 def test_plist16(self):2091 origin = [2092 " foobar ( foo,",2093 " bar,",2094 " baz )",2095 ""]2096 expected = [2097 " foobar ( foo,",2098 " bar,",2099 " baz )",2100 " blah",2101 ""]2102 self.setOrigin(origin)2103 self.setCursorPosition(2, 16)2104 self.enter()2105 self.type("blah")2106 self.verifyExpected(expected)2107 def test_plist17(self):2108 origin = [2109 " foobar ( foo ( bar,",2110 ""]2111 expected = [2112 " foobar ( foo ( bar,",2113 " baz",2114 ""]2115 self.setOrigin(origin)2116 self.setCursorPosition(0, 21)2117 self.enter()2118 self.type("baz")2119 self.verifyExpected(expected)2120 def test_plist18(self):2121 origin = [2122 " foobar ( foo ( bar,",2123 " baz ),",2124 ""]2125 expected = [2126 " foobar ( foo ( bar,",2127 " baz ),",2128 " blah",2129 ""]2130 self.setOrigin(origin)2131 self.setCursorPosition(1, 23)2132 self.enter()2133 self.type("blah")2134 self.verifyExpected(expected)2135 def test_plist19(self):2136 origin = [2137 " foobar ( foo ( bar,",2138 " baz ),",2139 " foobaz(),",2140 ""]2141 expected = [2142 " foobar ( foo ( bar,",2143 " baz ),",2144 " foobaz(),",2145 " blah",2146 ""]2147 self.setOrigin(origin)2148 self.setCursorPosition(2, 20)2149 self.enter()2150 self.type("blah")2151 self.verifyExpected(expected)2152 def test_plist20(self):2153 origin = [2154 " foobar ( foo ( bar,",2155 " baz ),",2156 " blah )",2157 ""]2158 expected = [2159 " foobar ( foo ( bar,",2160 " baz ),",2161 " blah )",2162 " foobaz",2163 ""]2164 self.setOrigin(origin)2165 self.setCursorPosition(2, 17)2166 self.enter()2167 self.type("foobaz")2168 self.verifyExpected(expected)2169class PlistComment(BaseTestClass):2170 def test_plist_comment1(self):2171 origin = [2172 " foobar(foo, # comment",2173 ""]2174 expected = [2175 " foobar(foo, # comment",2176 " bar",2177 ""]2178 self.setOrigin(origin)2179 self.setCursorPosition(0, 23)2180 self.enter()2181 self.type("bar")2182 self.verifyExpected(expected)2183 def test_plist_comment2(self):2184 origin = [2185 " foobar(foo, foo, # comment",2186 ""]2187 expected = [2188 " foobar(foo, foo, # comment",2189 " bar",2190 ""]2191 self.setOrigin(origin)2192 self.setCursorPosition(0, 28)2193 self.enter()2194 self.type("bar")2195 self.verifyExpected(expected)2196 def test_plist_comment3(self):2197 origin = [2198 " foobar(foo,",2199 " # comment",2200 " bar) # comment",2201 ""]2202 expected = [2203 " foobar(foo,",2204 " # comment",2205 " bar) # comment",2206 " blah",2207 ""]2208 self.setOrigin(origin)2209 self.setCursorPosition(2, 23)2210 self.enter()2211 self.type("blah")2212 self.verifyExpected(expected)2213 def test_plist_comment4(self):2214 origin = [2215 " foobar(foo,",2216 " bar, # comment",2217 " # comment",2218 ""]2219 expected = [2220 " foobar(foo,",2221 " bar, # comment",2222 " # comment",2223 " baz",2224 ""]2225 self.setOrigin(origin)2226 self.setCursorPosition(2, 18)2227 self.enter()2228 self.type("baz")2229 self.verifyExpected(expected)2230 def test_plist_comment5(self):2231 origin = [2232 " foobar(foo,",2233 " bar, bar, # comment",2234 " # comment",2235 ""]2236 expected = [2237 " foobar(foo,",2238 " bar, bar, # comment",2239 " # comment",2240 " baz",2241 ""]2242 self.setOrigin(origin)2243 self.setCursorPosition(2, 28)2244 self.enter()2245 self.type("baz")2246 self.verifyExpected(expected)2247 def test_plist_comment6(self):2248 origin = [2249 " foobar(foo,",2250 " bar,",2251 " baz) # comment,",2252 ""]2253 expected = [2254 " foobar(foo,",2255 " bar,",2256 " baz) # comment,",2257 " blah",2258 ""]2259 self.setOrigin(origin)2260 self.setCursorPosition(2, 24)2261 self.enter()2262 self.type("blah")2263 self.verifyExpected(expected)2264 def test_plist_comment7(self):2265 origin = [2266 " foobar(foo(bar, # comment",2267 " # comment",2268 ""]2269 expected = [2270 " foobar(foo(bar, # comment",2271 " # comment",2272 " baz",2273 ""]2274 self.setOrigin(origin)2275 self.setCursorPosition(1, 27)2276 self.enter()2277 self.type("baz")2278 self.verifyExpected(expected)2279 def test_plist_comment8(self):2280 origin = [2281 " foobar(foo(bar,",2282 " # comment",2283 " baz), # comment",2284 ""]2285 expected = [2286 " foobar(foo(bar,",2287 " # comment",2288 " baz), # comment",2289 " blah",2290 ""]2291 self.setOrigin(origin)2292 self.setCursorPosition(2, 28)2293 self.enter()2294 self.type("blah")2295 self.verifyExpected(expected)2296 def test_plist_comment9(self):2297 origin = [2298 " foobar(foo(bar,",2299 " baz), # comment",2300 " foobaz(), # comment",2301 " # comment",2302 ""]2303 expected = [2304 " foobar(foo(bar,",2305 " baz), # comment",2306 " foobaz(), # comment",2307 " # comment",2308 " blah",2309 ""]2310 self.setOrigin(origin)2311 self.setCursorPosition(3, 28)2312 self.enter()2313 self.type("blah")2314 self.verifyExpected(expected)2315 def test_plist_comment10(self):2316 origin = [2317 " foobar(foo(bar,",2318 " baz),",2319 " # comment",2320 " blah)",2321 " # comment",2322 ""]2323 expected = [2324 " foobar(foo(bar,",2325 " baz),",2326 " # comment",2327 " blah)",2328 " # comment",2329 " foobaz",2330 ""]2331 self.setOrigin(origin)2332 self.setCursorPosition(4, 16)2333 self.enter()2334 self.type("foobaz")2335 self.verifyExpected(expected)2336class Comment(BaseTestClass):2337 def test_comment1(self):2338 origin = [2339 "# comment1.txt",2340 "if foo",2341 " # Comment",2342 ""]2343 expected = [2344 "# comment1.txt",2345 "if foo",2346 " # Comment",2347 "end",2348 ""]2349 self.setOrigin(origin)2350 self.setCursorPosition(2, 11)2351 self.enter()2352 self.type("end")2353 self.verifyExpected(expected)2354 def test_comment2(self):2355 origin = [2356 "# comment2.txt",2357 "if foo",2358 " # Comment",2359 ""]2360 expected = [2361 "# comment2.txt",2362 "if foo",2363 " # Comment",2364 " bar",2365 "end",2366 ""]2367 self.setOrigin(origin)2368 self.setCursorPosition(2, 11)2369 self.enter()2370 self.type("bar")2371 self.enter()2372 self.type("end")2373 self.verifyExpected(expected)2374 def test_comment3(self):2375 origin = [2376 "# comment3.txt",2377 "if foo",2378 " # Comment",2379 ""]2380 expected = [2381 "# comment3.txt",2382 "if foo",2383 " # Comment",2384 " bar",2385 " # Another comment",2386 "end",2387 ""]2388 self.setOrigin(origin)2389 self.setCursorPosition(2, 11)2390 self.enter()2391 self.type("bar")2392 self.enter()2393 self.type("# Another comment")2394 self.enter()2395 self.type("end")2396 self.verifyExpected(expected)2397 def test_comment4(self):2398 origin = [2399 "# comment4.txt",2400 "if foo",2401 " # Comment",2402 ""]2403 expected = [2404 "# comment4.txt",2405 "if foo",2406 " # Comment",2407 " bar # Another comment",2408 "end",2409 ""]2410 self.setOrigin(origin)2411 self.setCursorPosition(2, 11)2412 self.enter()2413 self.type("bar # Another comment")2414 self.enter()2415 self.type("end")2416 self.verifyExpected(expected)2417 def test_comment5(self):2418 origin = [2419 "# comment5.txt",2420 "if foo",2421 " # Misplaced comment",2422 ""]2423 expected = [2424 "# comment5.txt",2425 "if foo",2426 " # Misplaced comment",2427 " bar",2428 "end",2429 ""]2430 self.setOrigin(origin)2431 self.setCursorPosition(2, 24)2432 self.enter()2433 self.type("bar")2434 self.enter()2435 self.type("end")2436 self.verifyExpected(expected)2437 def test_comment6(self):2438 origin = [2439 "# comment6.txt",2440 "if foo",2441 "# Misplaced comment",2442 ""]2443 expected = [2444 "# comment6.txt",2445 "if foo",2446 "# Misplaced comment",2447 " bar",2448 "end",2449 ""]2450 self.setOrigin(origin)2451 self.setCursorPosition(2, 19)2452 self.enter()2453 self.type("bar")2454 self.enter()2455 self.type("end")2456 self.verifyExpected(expected)2457class Heredoc(BaseTestClass):2458 def test_heredoc1(self):2459 origin = [2460 "doc = <<EOF",2461 ""]2462 expected = [2463 "doc = <<EOF",2464 "koko",2465 ""]2466 self.setOrigin(origin)2467 self.setCursorPosition(0, 11)2468 self.enter()2469 self.type("koko")2470 self.verifyExpected(expected)2471 def test_heredoc2(self):2472 origin = [2473 "doc = <<EOF",2474 ""]2475 expected = [2476 "doc = <<EOF",2477 "",2478 "koko",2479 ""]2480 self.setOrigin(origin)2481 self.setCursorPosition(0, 11)2482 self.enter()2483 self.enter()2484 self.type("koko")2485 self.verifyExpected(expected)2486 def test_heredoc3(self):2487 origin = [2488 "doc = <<EOF",2489 "if foo",2490 ""]2491 expected = [2492 "doc = <<EOF",2493 "if foo",2494 "koko",2495 ""]2496 self.setOrigin(origin)2497 self.setCursorPosition(1, 6)2498 self.enter()2499 self.type("koko")2500 self.verifyExpected(expected)2501 def test_heredoc4(self):2502 origin = [2503 "doc = <<EOF",2504 "if foo",2505 ""]2506 expected = [2507 "doc = <<EOF",2508 "if foo",2509 "",2510 "koko",2511 ""]2512 self.setOrigin(origin)2513 self.setCursorPosition(1, 6)2514 self.enter()2515 self.enter()2516 self.type("koko")2517 self.verifyExpected(expected)2518 def test_heredoc5(self):2519 origin = [2520 "if foo",2521 "doc = <<EOF",2522 ""]2523 expected = [2524 "if foo",2525 "doc = <<EOF",2526 "koko",2527 ""]2528 self.setOrigin(origin)2529 self.setCursorPosition(1, 11)2530 self.enter()2531 self.type("koko")2532 self.verifyExpected(expected)2533 def test_heredoc6(self):2534 origin = [2535 "if foo",2536 "doc = <<EOF",2537 ""]2538 expected = [2539 "if foo",2540 "doc = <<EOF",2541 "",2542 "koko",2543 ""]2544 self.setOrigin(origin)2545 self.setCursorPosition(1, 11)2546 self.enter()2547 self.enter()2548 self.type("koko")2549 self.verifyExpected(expected)2550class BlockComment(BaseTestClass):2551 def test_block_comment1(self):2552 origin = [2553 "=begin",2554 ""]2555 expected = [2556 "=begin",2557 "koko",2558 ""]2559 self.setOrigin(origin)2560 self.setCursorPosition(0, 6)2561 self.enter()2562 self.type("koko")2563 self.verifyExpected(expected)2564 def test_block_comment2(self):2565 origin = [2566 "=begin",2567 ""]2568 expected = [2569 "=begin",2570 "",2571 "koko",2572 ""]2573 self.setOrigin(origin)2574 self.setCursorPosition(0, 6)2575 self.enter()2576 self.enter()2577 self.type("koko")2578 self.verifyExpected(expected)2579 def test_block_comment3(self):2580 origin = [2581 "=begin",2582 "if foo",2583 ""]2584 expected = [2585 "=begin",2586 "if foo",2587 "koko",2588 ""]2589 self.setOrigin(origin)2590 self.setCursorPosition(1, 6)2591 self.enter()2592 self.type("koko")2593 self.verifyExpected(expected)2594 def test_block_comment4(self):2595 origin = [2596 "=begin",2597 "if foo",2598 ""]2599 expected = [2600 "=begin",2601 "if foo",2602 "",2603 "koko",2604 ""]2605 self.setOrigin(origin)2606 self.setCursorPosition(1, 6)2607 self.enter()2608 self.enter()2609 self.type("koko")2610 self.verifyExpected(expected)2611 def test_block_comment5(self):2612 origin = [2613 "if foo",2614 "=begin",2615 ""]2616 expected = [2617 "if foo",2618 "=begin",2619 "koko",2620 ""]2621 self.setOrigin(origin)2622 self.setCursorPosition(1, 6)2623 self.enter()2624 self.type("koko")2625 self.verifyExpected(expected)2626 def test_block_comment6(self):2627 origin = [2628 "if foo",2629 "=begin",2630 ""]2631 expected = [2632 "if foo",2633 "=begin",2634 "",2635 "koko",2636 ""]2637 self.setOrigin(origin)2638 self.setCursorPosition(1, 6)2639 self.enter()2640 self.enter()2641 self.type("koko")2642 self.verifyExpected(expected)2643 def test_block_comment7(self):2644 origin = [2645 "if foo",2646 "=begin",2647 "=end",2648 ""]2649 expected = [2650 "if foo",2651 "=begin",2652 "=end",2653 " koko",2654 ""]2655 self.setOrigin(origin)2656 self.setCursorPosition(2, 4)2657 self.enter()2658 self.type("koko")2659 self.verifyExpected(expected)2660 @unittest.expectedFailure2661 def test_block_comment8(self):2662 origin = [2663 "if foo",2664 "=begin",2665 "=end",2666 ""]2667 expected = [2668 "if foo",2669 "=begin",2670 "=end",2671 "",2672 " koko",2673 ""]2674 self.setOrigin(origin)2675 self.setCursorPosition(2, 4)2676 self.enter()2677 self.enter()2678 self.type("koko")2679 self.verifyExpected(expected)2680if __name__ == '__main__':...

Full Screen

Full Screen

test_cstyle.py

Source:test_cstyle.py Github

copy

Full Screen

...16 "int {",17 " ok",18 ""]19 self.setOrigin(origin)20 self.setCursorPosition(0,5);21 self.enter();22 self.type("ok");23 self.verifyExpected(expected)24 def test_top2(self):25 origin = [26 "",27 "int {",28 ""]29 expected = [30 "",31 "int {",32 " ok",33 ""]34 self.setOrigin(origin)35 self.setCursorPosition(1,5);36 self.enter();37 self.type("ok");38 self.verifyExpected(expected)39 def test_top3(self):40 origin = [41 "// should always indent after opening brace",42 "int {",43 ""]44 expected = [45 "// should always indent after opening brace",46 "int {",47 " ok",48 ""]49 self.setOrigin(origin)50 self.setCursorPosition(1,5);51 self.enter();52 self.type("ok");53 self.verifyExpected(expected)54 def test_top4(self):55 origin = [56 "// should always indent after opening brace",57 "",58 "int {",59 ""]60 expected = [61 "// should always indent after opening brace",62 "",63 "int {",64 " ok",65 ""]66 self.setOrigin(origin)67 self.setCursorPosition(2,5);68 self.enter();69 self.type("ok");70 self.verifyExpected(expected)71 def test_top5(self):72 origin = [73 ";",74 "int {",75 ""]76 expected = [77 ";",78 "int {",79 " ok",80 ""]81 self.setOrigin(origin)82 self.setCursorPosition(1,5);83 self.enter();84 self.type("ok");85 self.verifyExpected(expected)86 def test_top6(self):87 origin = [88 ":",89 "int {",90 ""]91 expected = [92 ":",93 "int {",94 " ok",95 ""]96 self.setOrigin(origin)97 self.setCursorPosition(1,5);98 self.enter();99 self.type("ok");100 self.verifyExpected(expected)101 def test_top7(self):102 origin = [103 "}",104 "int {",105 ""]106 expected = [107 "}",108 "int {",109 " ok",110 ""]111 self.setOrigin(origin)112 self.setCursorPosition(1,5);113 self.enter();114 self.type("ok");115 self.verifyExpected(expected)116 def test_top8(self):117 origin = [118 "{",119 "int {",120 ""]121 expected = [122 "{",123 "int {",124 " ok",125 ""]126 self.setOrigin(origin)127 self.setCursorPosition(1,5);128 self.enter();129 self.type("ok");130 self.verifyExpected(expected)131 def test_top9(self):132 origin = [133 ")",134 "int {",135 ""]136 expected = [137 ")",138 "int {",139 " ok",140 ""]141 self.setOrigin(origin)142 self.setCursorPosition(1,5);143 self.enter();144 self.type("ok");145 self.verifyExpected(expected)146 def test_top10(self):147 origin = [148 "(",149 "int {",150 ""]151 expected = [152 "(",153 "int {",154 " ok",155 ""]156 self.setOrigin(origin)157 self.setCursorPosition(1,5);158 self.enter();159 self.type("ok");160 self.verifyExpected(expected)161 def test_top11(self):162 origin = [163 "n",164 "int {",165 ""]166 expected = [167 "n",168 "int {",169 " ok",170 ""]171 self.setOrigin(origin)172 self.setCursorPosition(1,5);173 self.enter();174 self.type("ok");175 self.verifyExpected(expected)176 def test_top12(self):177 origin = [178 ";",179 "",180 "int {",181 ""]182 expected = [183 ";",184 "",185 "int {",186 " ok",187 ""]188 self.setOrigin(origin)189 self.setCursorPosition(2,5);190 self.enter();191 self.type("ok");192 self.verifyExpected(expected)193 def test_top13(self):194 origin = [195 ":",196 "",197 "int {",198 ""]199 expected = [200 ":",201 "",202 "int {",203 " ok",204 ""]205 self.setOrigin(origin)206 self.setCursorPosition(2,5);207 self.enter();208 self.type("ok");209 self.verifyExpected(expected)210 def test_top14(self):211 origin = [212 "}",213 "",214 "int {",215 ""]216 expected = [217 "}",218 "",219 "int {",220 " ok",221 ""]222 self.setOrigin(origin)223 self.setCursorPosition(2,5);224 self.enter();225 self.type("ok");226 self.verifyExpected(expected)227 def test_top15(self):228 origin = [229 "{",230 "",231 "int {",232 ""]233 expected = [234 "{",235 "",236 "int {",237 " ok",238 ""]239 self.setOrigin(origin)240 self.setCursorPosition(2,5);241 self.enter();242 self.type("ok");243 self.verifyExpected(expected)244 def test_top16(self):245 origin = [246 ")",247 "",248 "int {",249 ""]250 expected = [251 ")",252 "",253 "int {",254 " ok",255 ""]256 self.setOrigin(origin)257 self.setCursorPosition(2,5);258 self.enter();259 self.type("ok");260 self.verifyExpected(expected)261 def test_top17(self):262 origin = [263 "(",264 "",265 "int {",266 ""]267 expected = [268 "(",269 "",270 "int {",271 " ok",272 ""]273 self.setOrigin(origin)274 self.setCursorPosition(2,5);275 self.enter();276 self.type("ok");277 self.verifyExpected(expected)278 def test_top18(self):279 origin = [280 "n",281 "",282 "int {",283 ""]284 expected = [285 "n",286 "",287 "int {",288 " ok",289 ""]290 self.setOrigin(origin)291 self.setCursorPosition(2,5);292 self.enter();293 self.type("ok");294 self.verifyExpected(expected)295 def test_top19(self):296 origin = [297 "// leading comment should not cause second line to be indented",298 ""]299 expected = [300 "// leading comment should not cause second line to be indented",301 "ok",302 ""]303 self.setOrigin(origin)304 self.setCursorPosition(0,62);305 self.enter();306 self.type("ok");307 self.verifyExpected(expected)308class If(BaseTestClass):309 def test_if1(self):310 origin = [311 "int fla() {",312 " if (0<x)",313 ""]314 expected = [315 "int fla() {",316 " if (0<x)",317 " ok",318 ""]319 self.setOrigin(origin)320 self.setCursorPosition(1,10);321 self.enter();322 self.type("ok");323 self.verifyExpected(expected)324 def test_if2(self):325 origin = [326 "int fla() {",327 " if (0<x)",328 " x = 0;",329 ""]330 expected = [331 "int fla() {",332 " if (0<x)",333 " x = 0;",334 " ok",335 ""]336 self.setOrigin(origin)337 self.setCursorPosition(2,10);338 self.enter();339 self.type("ok");340 self.verifyExpected(expected)341 def test_if3(self):342 origin = [343 "int fla() {",344 " if (0<x)",345 " x = 0;",346 " else",347 ""]348 expected = [349 "int fla() {",350 " if (0<x)",351 " x = 0;",352 " else",353 " ok",354 ""]355 self.setOrigin(origin)356 self.setCursorPosition(3,6);357 self.enter();358 self.type("ok");359 self.verifyExpected(expected)360 def test_if4(self):361 origin = [362 "int fla() {",363 " if (0<x)",364 " x = 0;",365 " else",366 " x = -x;",367 ""]368 expected = [369 "int fla() {",370 " if (0<x)",371 " x = 0;",372 " else",373 " x = -x;",374 " ok",375 ""]376 self.setOrigin(origin)377 self.setCursorPosition(4,11);378 self.enter();379 self.type("ok");380 self.verifyExpected(expected)381 def test_if5(self):382 origin = [383 "int fla() {",384 " if (0<x)",385 " x = 0;",386 " else if (y<x)",387 ""]388 expected = [389 "int fla() {",390 " if (0<x)",391 " x = 0;",392 " else if (y<x)",393 " ok",394 ""]395 self.setOrigin(origin)396 self.setCursorPosition(3,15);397 self.enter();398 self.type("ok");399 self.verifyExpected(expected)400 def test_if6(self):401 origin = [402 "int fla() {",403 " if (0<x) x(0);",404 ""]405 expected = [406 "int fla() {",407 " if (0<x) x(0);",408 " ok",409 ""]410 self.setOrigin(origin)411 self.setCursorPosition(1,16);412 self.enter();413 self.type("ok");414 self.verifyExpected(expected)415 def test_if7(self):416 origin = [417 "int fla() {",418 " if (0<x)",419 " x = 0;",420 " else x(-1);",421 ""]422 expected = [423 "int fla() {",424 " if (0<x)",425 " x = 0;",426 " else x(-1);",427 " ok",428 ""]429 self.setOrigin(origin)430 self.setCursorPosition(3,13);431 self.enter();432 self.type("ok");433 self.verifyExpected(expected)434 def test_if8(self):435 origin = [436 "int fla() {",437 " if (0<x)",438 " x = 0;",439 " else if (y<x)",440 " y = x;",441 ""]442 expected = [443 "int fla() {",444 " if (0<x)",445 " x = 0;",446 " else if (y<x)",447 " y = x;",448 " ok",449 ""]450 self.setOrigin(origin)451 self.setCursorPosition(4,10);452 self.enter();453 self.type("ok");454 self.verifyExpected(expected)455 def test_if9(self):456 origin = [457 "int fla() {",458 " if (0<x)",459 " x = 0;",460 " else if (y<x) y = x;",461 ""]462 expected = [463 "int fla() {",464 " if (0<x)",465 " x = 0;",466 " else if (y<x) y = x;",467 " ok",468 ""]469 self.setOrigin(origin)470 self.setCursorPosition(3,22);471 self.enter();472 self.type("ok");473 self.verifyExpected(expected)474 def test_if10(self):475 origin = [476 "if () {}"]477 expected = [478 "if ()",479 "{}"]480 self.setOrigin(origin)481 self.setCursorPosition(0,5);482 self.enter();483 self.verifyExpected(expected)484 def test_if11(self):485 origin = [486 " if (0<x) {",487 " x = 0;",488 " }",489 "",490 "text;",491 ""]492 expected = [493 " if (0<x) {",494 " x = 0;",495 " }",496 "",497 "",498 " text;",499 ""]500 self.setOrigin(origin)501 self.setCursorPosition(4,0);502 self.enter();503 self.tab();504 self.verifyExpected(expected)505 def test_if_qutepart1(self):506 origin = [507 " if (1)",508 " {",509 " a = 7;"]510 expected = [511 " if (1)",512 " {",513 " a = 7;",514 " x"]515 self.setOrigin(origin)516 self.setCursorPosition(3, 11)517 self.enter()518 self.type('x')519 self.verifyExpected(expected)520class While(BaseTestClass):521 def test_while1(self):522 origin = [523 "int fla() {",524 " while (0<x)",525 ""]526 expected = [527 "int fla() {",528 " while (0<x)",529 " ok",530 ""]531 self.setOrigin(origin)532 self.setCursorPosition(1,13);533 self.enter();534 self.type("ok");535 self.verifyExpected(expected)536 def test_while2(self):537 origin = [538 "int fla() {",539 " while (0<x)",540 " x--;",541 ""]542 expected = [543 "int fla() {",544 " while (0<x)",545 " x--;",546 " ok",547 ""]548 self.setOrigin(origin)549 self.setCursorPosition(2,8);550 self.enter();551 self.type("ok");552 self.verifyExpected(expected)553 def test_while3(self):554 origin = [555 "int fla() {",556 " while (0<x) x();",557 ""]558 expected = [559 "int fla() {",560 " while (0<x) x();",561 " ok",562 ""]563 self.setOrigin(origin)564 self.setCursorPosition(1,18);565 self.enter();566 self.type("ok");567 self.verifyExpected(expected)568class For(BaseTestClass):569 def test_for1(self):570 origin = [571 "int main() {",572 " for (int a = 0;",573 ""]574 expected = [575 "int main() {",576 " for (int a = 0;",577 " b",578 ""]579 self.setOrigin(origin)580 self.setCursorPosition(1,17);581 self.enter();582 self.type("b");583 self.verifyExpected(expected)584 def test_for2(self):585 origin = [586 "int main() {",587 " for (int a = 0;",588 " b;",589 " c)",590 ""]591 expected = [592 "int main() {",593 " for (int a = 0;",594 " b;",595 " c) {",596 " ok",597 ""]598 self.setOrigin(origin)599 self.setCursorPosition(3,9);600 self.type(" {");601 self.enter();602 self.type("ok");603 self.verifyExpected(expected)604 def test_for3(self):605 origin = [606 "int fla() {",607 " for (;0<x;)",608 ""]609 expected = [610 "int fla() {",611 " for (;0<x;)",612 " ok",613 ""]614 self.setOrigin(origin)615 self.setCursorPosition(1,13);616 self.enter();617 self.type("ok");618 self.verifyExpected(expected)619 def test_for4(self):620 origin = [621 "int fla() {",622 " for (;0<x;)",623 " x--;",624 ""]625 expected = [626 "int fla() {",627 " for (;0<x;)",628 " x--;",629 " ok",630 ""]631 self.setOrigin(origin)632 self.setCursorPosition(2,8);633 self.enter();634 self.type("ok");635 self.verifyExpected(expected)636 def test_for5(self):637 origin = [638 "int fla() {",639 " for (;0<x;) x();",640 ""]641 expected = [642 "int fla() {",643 " for (;0<x;) x();",644 " ok",645 ""]646 self.setOrigin(origin)647 self.setCursorPosition(1,18);648 self.enter();649 self.type("ok");650 self.verifyExpected(expected)651class Do(BaseTestClass):652 def test_do1(self):653 origin = [654 "int fla() {",655 " do",656 ""]657 expected = [658 "int fla() {",659 " do",660 " ok",661 ""]662 self.setOrigin(origin)663 self.setCursorPosition(1,4);664 self.enter();665 self.type("ok");666 self.verifyExpected(expected)667 def test_do2(self):668 origin = [669 "int fla() {",670 " do",671 " x--;",672 ""]673 expected = [674 "int fla() {",675 " do",676 " x--;",677 " while",678 ""]679 self.setOrigin(origin)680 self.setCursorPosition(2,8);681 self.enter();682 self.type("while");683 self.verifyExpected(expected)684 def test_do3(self):685 origin = [686 "int fla() {",687 " do x();",688 ""]689 expected = [690 "int fla() {",691 " do x();",692 " while",693 ""]694 self.setOrigin(origin)695 self.setCursorPosition(1,9);696 self.enter();697 self.type("while");698 self.verifyExpected(expected)699class Switch(BaseTestClass):700 def test_switch1(self):701 origin = [702 " int foo() {",703 " switch (x) {",704 ""]705 expected = [706 " int foo() {",707 " switch (x) {",708 " case 0:",709 ""]710 self.setOrigin(origin)711 self.setCursorPosition(1,16);712 self.enter();713 self.type("case 0:");714 self.verifyExpected(expected)715 def test_switch2(self):716 origin = [717 " int foo() {",718 " switch (x) {",719 " case 0:",720 ""]721 expected = [722 " int foo() {",723 " switch (x) {",724 " case 0:",725 " ok",726 ""]727 self.setOrigin(origin)728 self.setCursorPosition(2,13);729 self.enter();730 self.type("ok");731 self.verifyExpected(expected)732 def test_switch3(self):733 origin = [734 " int foo() {",735 " switch (x) {",736 " case 0:",737 " ok;",738 ""]739 expected = [740 " int foo() {",741 " switch (x) {",742 " case 0:",743 " ok;",744 " case 1:",745 ""]746 self.setOrigin(origin)747 self.setCursorPosition(3,11);748 self.enter();749 self.type("case 1:");750 self.verifyExpected(expected)751 def test_switch4(self):752 origin = [753 " int foo() {",754 " switch (x) {",755 " case 0:",756 " ok;",757 " case 1:",758 ""]759 expected = [760 " int foo() {",761 " switch (x) {",762 " case 0:",763 " ok;",764 " case 1:;",765 " }",766 ""]767 self.setOrigin(origin)768 self.setCursorPosition(4,13);769 self.type(";");770 self.enter();771 self.type("}");772 self.verifyExpected(expected)773 def test_switch5(self):774 origin = [775 " int foo() {",776 " switch (x) {",777 " case 0:",778 ""]779 expected = [780 " int foo() {",781 " switch (x) {",782 " case 0:",783 " case 1:",784 ""]785 self.setOrigin(origin)786 self.setCursorPosition(2,13);787 self.enter();788 self.type("case 1:");789 self.verifyExpected(expected)790 def test_switch6(self):791 origin = [792 " int foo() {",793 " switch (x) {",794 " case 0:",795 " case 1:",796 ""]797 expected = [798 " int foo() {",799 " switch (x) {",800 " case 0:",801 " case 1: // bla",802 ""]803 self.setOrigin(origin)804 self.setCursorPosition(3,13);805 self.type(" // bla");806 self.verifyExpected(expected)807 def test_switch7(self):808 origin = [809 " int foo() {",810 " switch (x) {",811 " case 0:",812 " ok;",813 " case 1:",814 ""]815 expected = [816 " int foo() {",817 " switch (x) {",818 " case 0:",819 " ok;",820 " case 1:",821 " default:",822 " ;",823 ""]824 self.setOrigin(origin)825 self.setCursorPosition(4,13);826 self.enter();827 self.type("default:");828 self.enter();829 self.type(";");830 self.verifyExpected(expected)831 """ FIXME probably requires understanding, what is text and what is not832 def test_switch8(self):833 origin = [834 " int foo() {",835 " switch (x) {",836 " case '.':",837 " ok;",838 ""]839 expected = [840 " int foo() {",841 " switch (x) {",842 " case '.':",843 " ok;",844 " case ':'",845 ""]846 self.setOrigin(origin)847 self.setCursorPosition(3,11);848 self.enter();849 self.type("case ':'");850 self.verifyExpected(expected)851 """852 def test_switch9(self):853 origin = [854 " int foo() {",855 " switch (x) {",856 " case '.':",857 " ok;",858 " case ':'",859 ""]860 expected = [861 " int foo() {",862 " switch (x) {",863 " case '.':",864 " ok;",865 " case ':':",866 ""]867 self.setOrigin(origin)868 self.setCursorPosition(4,16);869 self.type(":");870 self.verifyExpected(expected)871 """ FIXME AK: I don't understand, why this tests shall pass. kate works like qutepart872 def test_switch10(self):873 origin = [874 " int foo() {",875 " switch (x) { // only first symbolic colon may reindent",876 " case '0':",877 ""]878 expected = [879 " int foo() {",880 " switch (x) { // only first symbolic colon may reindent",881 " case '0': case '1':",882 ""]883 self.setOrigin(origin)884 self.setCursorPosition(2,13);885 self.type(" case '1':");886 self.verifyExpected(expected)887 def test_switch11(self):888 origin = [889 " int foo() {",890 " switch (x) { // only first symbolic colon may reindent",891 " case '0': case '1':",892 ""]893 expected = [894 " int foo() {",895 " switch (x) { // only first symbolic colon may reindent",896 " case '0': case '1': case '2':",897 ""]898 self.setOrigin(origin)899 self.setCursorPosition(2,23);900 self.type(" case '2':");901 self.verifyExpected(expected)902 """903 def test_switch12(self):904 origin = [905 "int fla() {",906 " switch (x)",907 ""]908 expected = [909 "int fla() {",910 " switch (x)",911 " ok",912 ""]913 self.setOrigin(origin)914 self.setCursorPosition(1,12);915 self.enter();916 self.type("ok");917 self.verifyExpected(expected)918 """ FIXME AK: I don't understand, why this tests shall pass. kate works like qutepart919 def test_switch13(self):920 origin = [921 "int fla() {",922 " switch (x)",923 " x--;",924 ""]925 expected = [926 "int fla() {",927 " switch (x)",928 " x--;",929 " ok",930 ""]931 self.setOrigin(origin)932 self.setCursorPosition(2,8);933 self.enter();934 self.type("ok");935 self.verifyExpected(expected)936 """937 def test_switch14(self):938 origin = [939 "int fla() {",940 " switch (x) x();",941 ""]942 expected = [943 "int fla() {",944 " switch (x) x();",945 " ok",946 ""]947 self.setOrigin(origin)948 self.setCursorPosition(1,17);949 self.enter();950 self.type("ok");951 self.verifyExpected(expected)952class Visib(BaseTestClass):953 def test_visib1(self):954 origin = [955 "class A {",956 " public:",957 ""]958 expected = [959 "class A {",960 " public:",961 " A()",962 ""]963 self.setOrigin(origin)964 self.setCursorPosition(1,9);965 self.enter();966 self.type("A()");967 self.verifyExpected(expected)968 def test_visib2(self):969 origin = [970 "class A {",971 " public:",972 " A();",973 ""]974 expected = [975 "class A {",976 " public:",977 " A();",978 " protected:",979 ""]980 self.setOrigin(origin)981 self.setCursorPosition(2,8);982 self.enter();983 self.type("protected:");984 self.verifyExpected(expected)985 def test_visib3(self):986 origin = [987 "class A {",988 " public:",989 ""]990 expected = [991 "class A {",992 " public:",993 " protected:",994 ""]995 self.setOrigin(origin)996 self.setCursorPosition(1,9);997 self.enter();998 self.type("protected:");999 self.verifyExpected(expected)1000 def test_visib4(self):1001 origin = [1002 "class A {",1003 " public:",1004 ""]1005 expected = [1006 "class A {",1007 " public: // :",1008 ""]1009 self.setOrigin(origin)1010 self.setCursorPosition(1,20);1011 self.type(" // :");1012 self.verifyExpected(expected)1013 def test_visib5(self):1014 origin = [1015 "class A {",1016 " public:",1017 ""]1018 expected = [1019 "class A {",1020 ' public: x(":");',1021 ""]1022 self.setOrigin(origin)1023 self.setCursorPosition(1,20);1024 self.type(" x(\":\");");1025 self.verifyExpected(expected)1026 def test_visib6(self):1027 origin = [1028 "class A {",1029 " public:",1030 ""]1031 expected = [1032 "class A {",1033 " public: x(':');",1034 ""]1035 self.setOrigin(origin)1036 self.setCursorPosition(1,20);1037 self.type(" x(':');");1038 self.verifyExpected(expected)1039 def test_visib7(self):1040 origin = [1041 "class A {",1042 " public:",1043 ""]1044 expected = [1045 "class A {",1046 " public: X::x();",1047 ""]1048 self.setOrigin(origin)1049 self.setCursorPosition(1,20);1050 self.type(" X::x();");1051 self.verifyExpected(expected)1052 def test_visib8(self):1053 origin = [1054 "class A {",1055 " public:",1056 ""]1057 expected = [1058 "class A {",1059 " public: private:",1060 ""]1061 self.setOrigin(origin)1062 self.setCursorPosition(1,20);1063 self.type(" private:");1064 self.verifyExpected(expected)1065class Comment(BaseTestClass):1066 def test_comment1(self):1067 origin = [1068 " int foo() {",1069 " x;",1070 "// y;",1071 ""]1072 expected = [1073 " int foo() {",1074 " x;",1075 "// y;",1076 " ok",1077 ""]1078 self.setOrigin(origin)1079 self.setCursorPosition(2,9);1080 self.enter();1081 self.type("ok");1082 self.verifyExpected(expected)1083 def test_comment2(self):1084 origin = [1085 'foo(); // "comment"',1086 ""]1087 expected = [1088 'foo(); // "comment"',1089 "ok",1090 ""]1091 self.setOrigin(origin)1092 self.setCursorPosition(0,19);1093 self.enter();1094 self.type("ok");1095 self.verifyExpected(expected)1096class Aplist(BaseTestClass):1097 def test_aplist1(self):1098 origin = [1099 "int main(int argc, char **argv) {",1100 " somefunctioncall(argc,",1101 ""]1102 expected = [1103 "int main(int argc, char **argv) {",1104 " somefunctioncall(argc,",1105 " ok",1106 ""]1107 self.setOrigin(origin)1108 self.setCursorPosition(1,24);1109 self.enter();1110 self.type("ok");1111 self.verifyExpected(expected)1112 def test_aplist2(self):1113 origin = [1114 "int main(int argc, char **argv) {",1115 " somefunctioncall(argc,",1116 " ok,",1117 ""]1118 expected = [1119 "int main(int argc, char **argv) {",1120 " somefunctioncall(argc,",1121 " ok,",1122 " argv[0]",1123 ""]1124 self.setOrigin(origin)1125 self.setCursorPosition(2,22);1126 self.enter();1127 self.type("argv[0]");1128 self.verifyExpected(expected)1129 def test_aplist3(self):1130 origin = [1131 "int main(int argc, char **argv) {",1132 " somefunctioncall(argc,",1133 " ok,",1134 " argv[0]",1135 ""]1136 expected = [1137 "int main(int argc, char **argv) {",1138 " somefunctioncall(argc,",1139 " ok,",1140 " argv[0]);",1141 " ok",1142 ""]1143 self.setOrigin(origin)1144 self.setCursorPosition(3,26);1145 self.type(");");1146 self.enter();1147 self.type("ok");1148 self.verifyExpected(expected)1149 def test_aplist4(self):1150 origin = [1151 "int main(int argc, char **argv) {",1152 " somefunctioncall(argc,",1153 " nestedcall(var,",1154 ""]1155 expected = [1156 "int main(int argc, char **argv) {",1157 " somefunctioncall(argc,",1158 " nestedcall(var,",1159 " ok",1160 ""]1161 self.setOrigin(origin)1162 self.setCursorPosition(2,34);1163 self.enter();1164 self.type("ok");1165 self.verifyExpected(expected)1166 def test_aplist5(self):1167 origin = [1168 "int main(int argc, char **argv) {",1169 " f1(argc,",1170 " f2(var,",1171 " ok",1172 ""]1173 expected = [1174 "int main(int argc, char **argv) {",1175 " f1(argc,",1176 " f2(var,",1177 " ok),",1178 " argv",1179 ""]1180 self.setOrigin(origin)1181 self.setCursorPosition(3,32);1182 self.type("),");1183 self.enter();1184 self.type("argv");1185 self.verifyExpected(expected)1186 def test_aplist6(self):1187 origin = [1188 "int main(int argc, char **argv) {",1189 " f1(argc,",1190 " f2(var,",1191 " ok",1192 ""]1193 expected = [1194 "int main(int argc, char **argv) {",1195 " f1(argc,",1196 " f2(var,",1197 " ok));",1198 " ok",1199 ""]1200 self.setOrigin(origin)1201 self.setCursorPosition(3,32);1202 self.type("));");1203 self.enter();1204 self.type("ok");1205 self.verifyExpected(expected)1206 def test_aplist8(self):1207 origin = [1208 "int main(int argc, char **argv) {",1209 " somefunctioncall(nestedcall(var,",1210 ""]1211 expected = [1212 "int main(int argc, char **argv) {",1213 " somefunctioncall(nestedcall(var,",1214 " ok",1215 ""]1216 self.setOrigin(origin)1217 self.setCursorPosition(1,34);1218 self.enter();1219 self.type("ok");1220 self.verifyExpected(expected)1221 def test_aplist9(self):1222 origin = [1223 "int main(int argc, char **argv) {",1224 " f1(f2(var,",1225 " ok",1226 ""]1227 expected = [1228 "int main(int argc, char **argv) {",1229 " f1(f2(var,",1230 " ok),",1231 " var",1232 ""]1233 self.setOrigin(origin)1234 self.setCursorPosition(2,32);1235 self.type("),");1236 self.enter();1237 self.type("var");1238 self.verifyExpected(expected)1239 def test_aplist10(self):1240 origin = [1241 "int main(int argc, char **argv) {",1242 " somefunctioncall(",1243 ""]1244 expected = [1245 "int main(int argc, char **argv) {",1246 " somefunctioncall(",1247 " ok",1248 ""]1249 self.setOrigin(origin)1250 self.setCursorPosition(1,19);1251 self.enter();1252 self.type("ok");1253 self.verifyExpected(expected)1254 def test_aplist11(self):1255 origin = [1256 "int main(int argc, char **argv) {",1257 " somefunctioncall(",1258 " ok",1259 ""]1260 expected = [1261 "int main(int argc, char **argv) {",1262 " somefunctioncall(",1263 " ok",1264 " )",1265 ""]1266 self.setOrigin(origin)1267 self.setCursorPosition(2,21);1268 self.enter();1269 self.type(")");1270 self.verifyExpected(expected)1271 def test_aplist12(self):1272 origin = [1273 "int main(int argc, char **argv) {",1274 " somefunctioncall(",1275 " ok",1276 " )",1277 ""]1278 expected = [1279 "int main(int argc, char **argv) {",1280 " somefunctioncall(",1281 " ok",1282 " );",1283 " ok",1284 ""]1285 self.setOrigin(origin)1286 self.setCursorPosition(3,19);1287 self.type(";");1288 self.enter();1289 self.type("ok");1290 self.verifyExpected(expected)1291 def test_aplist13(self):1292 origin = [1293 "int main(int argc, char **argv) {",1294 " somefunctioncall(argc,argv,",1295 " ok,",1296 ""]1297 expected = [1298 "int main(int argc, char **argv) {",1299 " somefunctioncall(argc,",1300 " argv,",1301 " ok,",1302 ""]1303 self.setOrigin(origin)1304 self.setCursorPosition(1,24);1305 self.enter();1306 self.verifyExpected(expected)1307 def test_aplist14(self):1308 origin = [1309 "int main(int argc, char **argv) {",1310 " somefunctioncall(argc, argv,",1311 " ok,",1312 ""]1313 expected = [1314 "int main(int argc, char **argv) {",1315 " somefunctioncall(argc,",1316 " argv,",1317 " ok,",1318 ""]1319 self.setOrigin(origin)1320 self.setCursorPosition(1,24);1321 self.enter();1322 self.verifyExpected(expected)1323 def test_aplist15(self):1324 origin = [1325 "int main(int argc, char **argv) {",1326 " somefunctioncall(argc,",1327 " argv,argx,",1328 " ok,",1329 ""]1330 expected = [1331 "int main(int argc, char **argv) {",1332 " somefunctioncall(argc,",1333 " argv,",1334 " argx,",1335 " ok,",1336 ""]1337 self.setOrigin(origin)1338 self.setCursorPosition(2,24);1339 self.enter();1340 self.verifyExpected(expected)1341 def test_aplist16(self):1342 origin = [1343 "int main(int argc, char **argv) {",1344 " somefunctioncall(argc,",1345 " argv, argx,",1346 " ok,",1347 ""]1348 expected = [1349 "int main(int argc, char **argv) {",1350 " somefunctioncall(argc,",1351 " argv,",1352 " argx,",1353 " ok,",1354 ""]1355 self.setOrigin(origin)1356 self.setCursorPosition(2,24);1357 self.enter();1358 self.verifyExpected(expected)1359 def test_aplist17(self):1360 origin = [1361 "int main(int argc, char **argv) {",1362 " somefunctioncall(argc,",1363 " nestedcall(var,argv,",1364 ""]1365 expected = [1366 "int main(int argc, char **argv) {",1367 " somefunctioncall(argc,",1368 " nestedcall(var,",1369 " argv,",1370 ""]1371 self.setOrigin(origin)1372 self.setCursorPosition(2,34);1373 self.enter();1374 self.verifyExpected(expected)1375 def test_aplist18(self):1376 origin = [1377 "int main(int argc, char **argv) {",1378 " somefunctioncall(argc,",1379 " nestedcall(var, argv,",1380 ""]1381 expected = [1382 "int main(int argc, char **argv) {",1383 " somefunctioncall(argc,",1384 " nestedcall(var,",1385 " argv,",1386 ""]1387 self.setOrigin(origin)1388 self.setCursorPosition(2,34);1389 self.enter();1390 self.verifyExpected(expected)1391 def test_aplist19(self):1392 origin = [1393 "int main(int argc, char **argv) {",1394 " somefunctioncall(argc,",1395 " nestedcall(var,",1396 " argv,argx,",1397 ""]1398 expected = [1399 "int main(int argc, char **argv) {",1400 " somefunctioncall(argc,",1401 " nestedcall(var,",1402 " argv,",1403 " argx,",1404 ""]1405 self.setOrigin(origin)1406 self.setCursorPosition(3,35);1407 self.enter();1408 self.verifyExpected(expected)1409 def test_aplist20(self):1410 origin = [1411 "int main(int argc, char **argv) {",1412 " somefunctioncall(argc,",1413 " nestedcall(var,",1414 " argv, argx,",1415 ""]1416 expected = [1417 "int main(int argc, char **argv) {",1418 " somefunctioncall(argc,",1419 " nestedcall(var,",1420 " argv,",1421 " argx,",1422 ""]1423 self.setOrigin(origin)1424 self.setCursorPosition(3,35);1425 self.enter();1426 self.verifyExpected(expected)1427 def test_aplist21(self):1428 """ Tabs are used """1429 origin = [1430 "\t\t fu1(argc,",1431 ""]1432 expected = [1433 "\t\t fu1(argc,",1434 " argv",1435 ""]1436 self.setOrigin(origin)1437 self.setCursorPosition(0, 12)1438 self.enter()1439 self.type("argv")1440 self.verifyExpected(expected)1441class OpenPar(BaseTestClass):1442 def test_openpar1(self):1443 origin = [1444 "int main() {",1445 ""]1446 expected = [1447 "int main() {",1448 " ok",1449 ""]1450 self.setOrigin(origin)1451 self.setCursorPosition(0,12);1452 self.enter();1453 self.type("ok");1454 self.verifyExpected(expected)1455 def test_openpar2(self):1456 origin = [1457 "int main()",1458 ""]1459 expected = [1460 "int main()",1461 "{",1462 " ok",1463 ""]1464 self.setOrigin(origin)1465 self.setCursorPosition(0,10);1466 self.enter();1467 self.type("{");1468 self.enter();1469 self.type("ok");1470 self.verifyExpected(expected)1471 def test_openpar3(self):1472 origin = [1473 "int main() {bla",1474 ""]1475 expected = [1476 "int main() {",1477 " bla",1478 ""]1479 self.setOrigin(origin)1480 self.setCursorPosition(0,12);1481 self.enter();1482 self.verifyExpected(expected)1483 def test_openpar4(self):1484 origin = [1485 "int main() { bla",1486 ""]1487 expected = [1488 "int main() {",1489 " bla",1490 ""]1491 self.setOrigin(origin)1492 self.setCursorPosition(0,12);1493 self.enter();1494 self.verifyExpected(expected)1495 def test_openpar5(self):1496 origin = [1497 "int main() {foo();",1498 ""]1499 expected = [1500 "int main() {",1501 " foo();",1502 ""]1503 self.setOrigin(origin)1504 self.setCursorPosition(0,12);1505 self.enter();1506 self.verifyExpected(expected)1507 def test_openpar6(self):1508 origin = [1509 "int main()",1510 "{bla"]1511 expected = [1512 "int main()",1513 "{",1514 " bla"]1515 self.setOrigin(origin)1516 self.setCursorPosition(1,1);1517 self.enter();1518 self.verifyExpected(expected)1519 def test_openpar7(self):1520 origin = [1521 "int main()",1522 "{ bla",1523 ""]1524 expected = [1525 "int main()",1526 "{",1527 " bla",1528 ""]1529 self.setOrigin(origin)1530 self.setCursorPosition(1,1);1531 self.enter();1532 self.verifyExpected(expected)1533 def test_openpar8(self):1534 origin = [1535 "int main()",1536 "{foo();",1537 ""]1538 expected = [1539 "int main()",1540 "{",1541 " foo();",1542 ""]1543 self.setOrigin(origin)1544 self.setCursorPosition(1,1);1545 self.enter();1546 self.verifyExpected(expected)1547 def test_openpar9(self):1548 origin = [1549 "int main() {",1550 " if (x) {",1551 " a;",1552 " } else",1553 ""]1554 expected = [1555 "int main() {",1556 " if (x) {",1557 " a;",1558 " } else {",1559 " ok",1560 ""]1561 self.setOrigin(origin)1562 self.setCursorPosition(3,8);1563 self.type(" {");1564 self.enter();1565 self.type("ok");1566 self.verifyExpected(expected)1567 def test_openpar10(self):1568 origin = [1569 "int main() {",1570 " if (x) {",1571 " a;",1572 " } else if (y, z)",1573 ""]1574 expected = [1575 "int main() {",1576 " if (x) {",1577 " a;",1578 " } else if (y, z) {",1579 " ok",1580 ""]1581 self.setOrigin(origin)1582 self.setCursorPosition(3,18);1583 self.type(" {");1584 self.enter();1585 self.type("ok");1586 self.verifyExpected(expected)1587class ClosPar(BaseTestClass):1588 def test_clospar1(self):1589 origin = [1590 "int main() {",1591 " ok;",1592 ""]1593 expected = [1594 "int main() {",1595 " ok;",1596 "}",1597 ""]1598 self.setOrigin(origin)1599 self.setCursorPosition(1,5);1600 self.enter();1601 self.type("}");1602 self.verifyExpected(expected)1603 def test_clospar2(self):1604 origin = [1605 "int main()",1606 "{",1607 " ok;",1608 ""]1609 expected = [1610 "int main()",1611 "{",1612 " ok;",1613 "}",1614 ""]1615 self.setOrigin(origin)1616 self.setCursorPosition(2,5);1617 self.enter();1618 self.type("}");1619 self.verifyExpected(expected)1620 def test_clospar3(self):1621 origin = [1622 "int main() {",1623 " ok;}",1624 ""]1625 expected = [1626 "int main() {",1627 " ok;",1628 " ",1629 "}",1630 ""]1631 self.setOrigin(origin)1632 self.setCursorPosition(1,5);1633 self.enter();1634 self.verifyExpected(expected)1635 def test_clospar4(self):1636 origin = [1637 "int main() {",1638 " for() {",1639 " x;}",1640 ""]1641 expected = [1642 "int main() {",1643 " for() {",1644 " x;",1645 " ",1646 " }",1647 ""]1648 self.setOrigin(origin)1649 self.setCursorPosition(2,6);1650 self.enter();1651 self.verifyExpected(expected)1652class PList(BaseTestClass):1653 def test_plist1(self):1654 origin = [1655 "int fla(int x,",1656 ""]1657 expected = [1658 "int fla(int x,",1659 " short u",1660 ""]1661 self.setOrigin(origin)1662 self.setCursorPosition(0,14);1663 self.enter();1664 self.type("short u");1665 self.verifyExpected(expected)1666 def test_plist2(self):1667 origin = [1668 "int fla(int x,",1669 " short u",1670 ""]1671 expected = [1672 "int fla(int x,",1673 " short u,",1674 ""]1675 self.setOrigin(origin)1676 self.setCursorPosition(1,15);1677 self.type(",");1678 self.verifyExpected(expected)1679 def test_plist3(self):1680 origin = [1681 "int fla(int x,",1682 " short u,",1683 ""]1684 expected = [1685 "int fla(int x,",1686 " short u,",1687 " char c)",1688 ""]1689 self.setOrigin(origin)1690 self.setCursorPosition(1,16);1691 self.enter();1692 self.type("char c)");1693 self.verifyExpected(expected)1694 def test_plist4(self):1695 origin = [1696 "int fla(int x,",1697 " short u,",1698 " char c)",1699 ""]1700 expected = [1701 "int fla(int x,",1702 " short u,",1703 " char c)",1704 "{",1705 ""]1706 self.setOrigin(origin)1707 self.setCursorPosition(2,15);1708 self.enter();1709 self.type("{");1710 self.verifyExpected(expected)1711 def test_plist5(self):1712 origin = [1713 "int fla(int x,",1714 " short u,",1715 " char c)",1716 ""]1717 expected = [1718 "int fla(int x,",1719 " short u,",1720 " char c) {",1721 " ok",1722 ""]1723 self.setOrigin(origin)1724 self.setCursorPosition(2,15);1725 self.type(" {");1726 self.enter();1727 self.type("ok");1728 self.verifyExpected(expected)1729 def test_plist6(self):1730 origin = [1731 "uint8_t func( uint8_t p1, uint8_t p2)",1732 ""]1733 expected = [1734 "uint8_t func( uint8_t p1,",1735 " uint8_t p2)",1736 ""]1737 self.setOrigin(origin)1738 # bug:874151739 self.setCursorPosition(0,25);1740 self.enter();1741 self.verifyExpected(expected)1742 def test_plist7(self):1743 origin = [1744 "",1745 "uint8_t func( uint8_t p1, uint8_t p2)",1746 ""]1747 expected = [1748 "",1749 "uint8_t func( uint8_t p1,",1750 " uint8_t p2)",1751 ""]1752 self.setOrigin(origin)1753 # bug:874151754 self.setCursorPosition(1,25);1755 self.enter();1756 self.verifyExpected(expected)1757 def test_plist8(self):1758 origin = [1759 "int fla(int x,short u,char c)",1760 ""]1761 expected = [1762 "int fla(int x,",1763 " short u,char c)",1764 ""]1765 self.setOrigin(origin)1766 self.setCursorPosition(0,14);1767 self.enter();1768 self.verifyExpected(expected)1769 def test_plist9(self):1770 origin = [1771 "int fla(int x,",1772 " short u,char c)",1773 ""]1774 expected = [1775 "int fla(int x,",1776 " short u,",1777 " char c)",1778 ""]1779 self.setOrigin(origin)1780 self.setCursorPosition(1,16);1781 self.enter();1782 self.verifyExpected(expected)1783 """ FIXME AK: I don't understand, why this tests shall pass. kate works like qutepart1784 def test_plist10(self):1785 origin = [1786 "int fla(int x,short u,char c)",1787 ""]1788 expected = [1789 "int fla(",1790 " int x,short u,char c)",1791 ""]1792 self.setOrigin(origin)1793 self.setCursorPosition(0,8);1794 self.enter();1795 self.verifyExpected(expected)1796 """1797 def test_plist11(self):1798 origin = [1799 "int fla(",1800 " int x,short u,char c)",1801 ""]1802 expected = [1803 "int fla(",1804 " int x,",1805 " short u,char c)",1806 ""]1807 self.setOrigin(origin)1808 self.setCursorPosition(1,14);1809 self.enter();1810 self.verifyExpected(expected)1811 def test_plist12(self):1812 origin = [1813 "int fla(",1814 " int x,",1815 " short u,char c)",1816 ""]1817 expected = [1818 "int fla(",1819 " int x,",1820 " short u,",1821 " char c)",1822 ""]1823 self.setOrigin(origin)1824 self.setCursorPosition(2,16);1825 self.enter();1826 self.verifyExpected(expected)1827 def test_plist13(self):1828 origin = [1829 "int fla(",1830 " int x,",1831 " short u,",1832 " char c)",1833 ""]1834 expected = [1835 "int fla(",1836 " int x,",1837 " short u,",1838 " char c",1839 " )",1840 ""]1841 self.setOrigin(origin)1842 self.setCursorPosition(3,14);1843 self.enter();1844 self.verifyExpected(expected)1845 """ FIXME AK: I don't understand, why this tests shall pass. kate works like qutepart1846 def test_plist14(self):1847 origin = [1848 "int b() {",1849 "}",1850 "int fla(int x,short u,char c)",1851 ""]1852 expected = [1853 "int b() {",1854 "}",1855 "int fla(",1856 " int x,short u,char c)",1857 ""]1858 self.setOrigin(origin)1859 self.setCursorPosition(2,8);1860 self.enter();1861 self.verifyExpected(expected)1862 """1863 def test_plist15(self):1864 origin = [1865 "int fla(",1866 " int x,short u,char c",1867 " )",1868 ""]1869 expected = [1870 "int fla(",1871 " int x,",1872 " short u,char c",1873 " )",1874 ""]1875 self.setOrigin(origin)1876 self.setCursorPosition(1,14);1877 self.enter();1878 self.verifyExpected(expected)1879 def test_plist16(self):1880 origin = [1881 "int fla(",1882 " int x,short long_var_name,char c)",1883 ""]1884 expected = [1885 "int fla(",1886 " int x,",1887 " short long_var_name,char c)",1888 ""]1889 self.setOrigin(origin)1890 self.setCursorPosition(1,14);1891 self.enter();1892 self.verifyExpected(expected)1893 def test_plist17(self):1894 origin = [1895 "int fla(",1896 " int x,short long_var_name,",1897 " char c)",1898 ""]1899 expected = [1900 "int fla(",1901 " int x,",1902 " short long_var_name,",1903 " char c)",1904 ""]1905 self.setOrigin(origin)1906 self.setCursorPosition(1,14);1907 self.enter();1908 self.verifyExpected(expected)1909 def test_plist18(self):1910 origin = [1911 "void flp() {",1912 "}",1913 "",1914 "int fla(",1915 " int x,short long_var_name,",1916 " char c)",1917 ""]1918 expected = [1919 "void flp() {",1920 "}",1921 "",1922 "int fla(",1923 " int x,",1924 " short long_var_name,",1925 " char c)",1926 ""]1927 self.setOrigin(origin)1928 self.setCursorPosition(4,14);1929 self.enter();1930 self.verifyExpected(expected)1931 def test_plist19(self):1932 origin = [1933 "int x() {",1934 "}",1935 "int fla(",1936 " int x,short u,char c",1937 " )",1938 ""]1939 expected = [1940 "int x() {",1941 "}",1942 "int fla(",1943 " int x,",1944 " short u,char c",1945 " )",1946 ""]1947 self.setOrigin(origin)1948 self.setCursorPosition(3,14);1949 self.enter();1950 self.verifyExpected(expected)1951 def test_plist20(self):1952 origin = [1953 "void x() {",1954 "}",1955 "int fla(",1956 " int x,",1957 " short u,",1958 " char c)",1959 ""]1960 expected = [1961 "void x() {",1962 "}",1963 "int fla(",1964 " int x,",1965 " short u,",1966 " char c",1967 " )",1968 ""]1969 self.setOrigin(origin)1970 self.setCursorPosition(5,14);1971 self.enter();1972 self.verifyExpected(expected)1973 def test_plist21(self):1974 origin = [1975 "int x() {",1976 "}",1977 "int fla(",1978 " int x,",1979 " short u,char c)",1980 ""]1981 expected = [1982 "int x() {",1983 "}",1984 "int fla(",1985 " int x,",1986 " short u,",1987 " char c)",1988 ""]1989 self.setOrigin(origin)1990 self.setCursorPosition(4,16);1991 self.enter();1992 self.verifyExpected(expected)1993 def test_plist22(self):1994 origin = [1995 "int b() {",1996 "}",1997 "int fla(",1998 " int x,short u,char c)",1999 ""]2000 expected = [2001 "int b() {",2002 "}",2003 "int fla(",2004 " int x,",2005 " short u,char c)",2006 ""]2007 self.setOrigin(origin)2008 self.setCursorPosition(3,14);2009 self.enter();2010 self.verifyExpected(expected)2011 def test_plist24(self):2012 origin = [2013 "int b() {",2014 "}",2015 "int flablabberwabber(",2016 " int lonng,short lonngearr,char shrt)",2017 ""]2018 expected = [2019 "int b() {",2020 "}",2021 "int flablabberwabber(",2022 " int lonng,",2023 " short lonngearr,char shrt)",2024 ""]2025 self.setOrigin(origin)2026 self.setCursorPosition(3,31);2027 self.enter();2028 self.verifyExpected(expected)2029 def test_plist25(self):2030 origin = [2031 "int fla(",2032 " int x,",2033 " short u,",2034 " char c)",2035 ""]2036 expected = [2037 "int fla(",2038 " int x,",2039 " short u,",2040 " char c",2041 ")",2042 ""]2043 self.setOrigin(origin)2044 self.setCursorPosition(3,8);2045 self.enter();2046 self.verifyExpected(expected)2047class Comma(BaseTestClass):2048 def test_comma1(self):2049 origin = [2050 "int fla() {",2051 " double x,",2052 ""]2053 expected = [2054 "int fla() {",2055 " double x,",2056 " ok",2057 ""]2058 self.setOrigin(origin)2059 self.setCursorPosition(1,11);2060 self.enter();2061 self.type("ok");2062 self.verifyExpected(expected)2063 def test_comma2(self):2064 origin = [2065 "int fla() {",2066 " double x,y;",2067 ""]2068 expected = [2069 "int fla() {",2070 " double x,",2071 " y;",2072 ""]2073 self.setOrigin(origin)2074 self.setCursorPosition(1,11);2075 self.enter();2076 self.verifyExpected(expected)2077 def test_comma3(self):2078 origin = [2079 "int fla() {",2080 " b = 1,",2081 ""]2082 expected = [2083 "int fla() {",2084 " b = 1,",2085 " ok",2086 ""]2087 self.setOrigin(origin)2088 self.setCursorPosition(1,8);2089 self.enter();2090 self.type("ok");2091 self.verifyExpected(expected)2092 def test_comma4(self):2093 origin = [2094 "int fla() {",2095 " b = 1,c = 2;",2096 ""]2097 expected = [2098 "int fla() {",2099 " b = 1,",2100 " c = 2;",2101 ""]2102 self.setOrigin(origin)2103 self.setCursorPosition(1,8);2104 self.enter();2105 self.verifyExpected(expected)2106 def test_comma5(self):2107 origin = [2108 "double x,",2109 ""]2110 expected = [2111 "double x,",2112 "ok",2113 ""]2114 self.setOrigin(origin)2115 self.setCursorPosition(0,9);2116 self.enter();2117 self.type("ok");2118 self.verifyExpected(expected)2119 def test_comma6(self):2120 origin = [2121 "double x,y;",2122 ""]2123 expected = [2124 "double x,",2125 "y;",2126 ""]2127 self.setOrigin(origin)2128 self.setCursorPosition(0,9);2129 self.enter();2130 self.verifyExpected(expected)2131class Normal(BaseTestClass):2132 def test_normal1(self):2133 origin = [2134 "int main() {",2135 " bla;"]2136 expected = [2137 "int main() {",2138 " bla;",2139 " ok;"]2140 self.setOrigin(origin)2141 self.setCursorPosition(1,8);2142 self.enter();2143 self.type("ok;");2144 self.verifyExpected(expected)2145 def test_normal2(self):2146 origin = [2147 "int main() {",2148 " bla;blu;"]2149 expected = [2150 "int main() {",2151 " bla;",2152 " blu;"]2153 self.setOrigin(origin)2154 self.setCursorPosition(1,8);2155 self.enter();2156 self.verifyExpected(expected)2157 def test_normal3(self):2158 origin = [2159 "int main() {",2160 " bla; blu;",2161 ""]2162 expected = [2163 "int main() {",2164 " bla;",2165 " blu;",2166 ""]2167 self.setOrigin(origin)2168 self.setCursorPosition(1,8);2169 self.enter();2170 self.verifyExpected(expected)2171class Using(BaseTestClass):2172 """ FIXME AK: I don't understand, why this tests shall pass. kate works like qutepart2173 def test_using1(self):2174 origin = [2175 "using",2176 ""]2177 expected = [2178 "using",2179 " ok;",2180 ""]2181 self.setOrigin(origin)2182 self.setCursorPosition(0,5);2183 self.enter();2184 self.type("ok");2185 self.verifyExpected(expected)2186 def test_using2(self):2187 origin = [2188 "using",2189 " std::vector;",2190 ""]2191 expected = [2192 "using",2193 " std::vector;",2194 "ok",2195 ""]2196 self.setOrigin(origin)2197 self.setCursorPosition(1,14);2198 self.enter();2199 self.type("ok");2200 self.verifyExpected(expected)2201 """2202 def test_using3(self):2203 origin = [2204 "using std::vector;",2205 ""]2206 expected = [2207 "using std::vector;",2208 "ok",2209 ""]2210 self.setOrigin(origin)2211 self.setCursorPosition(0,18);2212 self.enter();2213 self.type("ok");2214 self.verifyExpected(expected)2215class Doxygen(BaseTestClass):2216 def test_doxygen1(self):2217 origin = [2218 "class A {",2219 " /**",2220 ""]2221 expected = [2222 "class A {",2223 " /**",2224 " * constructor",2225 ""]2226 self.setOrigin(origin)2227 self.setCursorPosition(1,5);2228 self.enter();2229 self.type("constructor");2230 self.verifyExpected(expected)2231 def test_doxygen2(self):2232 origin = [2233 "class A {",2234 " /**",2235 " * constructor",2236 ""]2237 expected = [2238 "class A {",2239 " /**",2240 " * constructor",2241 " * @param x foo",2242 ""]2243 self.setOrigin(origin)2244 self.setCursorPosition(2,16);2245 self.enter();2246 self.type("@param x foo");2247 self.verifyExpected(expected)2248 def test_doxygen3(self):2249 origin = [2250 "class A {",2251 " /**",2252 " * constructor",2253 " * @param x foo",2254 ""]2255 expected = [2256 "class A {",2257 " /**",2258 " * constructor",2259 " * @param x foo",2260 " */",2261 ""]2262 self.setOrigin(origin)2263 self.setCursorPosition(3,17);2264 self.enter();2265 self.type("/");2266 self.verifyExpected(expected)2267 def test_doxygen4(self):2268 origin = [2269 "class A {",2270 " /**",2271 " * constructor",2272 " * @param x foo",2273 " */",2274 ""]2275 expected = [2276 "class A {",2277 " /**",2278 " * constructor",2279 " * @param x foo",2280 " */",2281 " ok",2282 ""]2283 self.setOrigin(origin)2284 self.setCursorPosition(4,5);2285 self.enter();2286 self.type("ok");2287 self.verifyExpected(expected)2288 def test_doxygen5(self):2289 origin = [2290 "class A {",2291 " /**",2292 ""]2293 expected = [2294 "class A {",2295 " /** constructor */",2296 ""]2297 self.setOrigin(origin)2298 self.setCursorPosition(1,5);2299 self.type(" constructor */");2300 self.verifyExpected(expected)2301 def test_doxygen6(self):2302 origin = [2303 "class A {",2304 " /** constructor */",2305 ""]2306 expected = [2307 "class A {",2308 " /** constructor */",2309 " ok",2310 ""]2311 self.setOrigin(origin)2312 self.setCursorPosition(1,20);2313 self.enter();2314 self.type("ok");2315 self.verifyExpected(expected)2316 def test_doxygen7(self):2317 origin = [2318 "class A {",2319 " int foo(); /** unorthodox doxygen comment */",2320 ""]2321 expected = [2322 "class A {",2323 " int foo(); /** unorthodox doxygen comment */",2324 " ok",2325 ""]2326 self.setOrigin(origin)2327 self.setCursorPosition(1,46);2328 self.enter();2329 self.type("ok");2330 self.verifyExpected(expected)2331 def test_doxygen8(self):2332 origin = [2333 "/** unorthodox doxygen comment */ a;",2334 ""]2335 expected = [2336 "/** unorthodox doxygen comment */ a;",2337 "ok",2338 ""]2339 self.setOrigin(origin)2340 self.setCursorPosition(0, 36);2341 self.enter();2342 self.type("ok");2343 self.verifyExpected(expected)2344class Prep(BaseTestClass):2345 def test_prep1(self):2346 origin = [2347 " int foo() {",2348 " x;",2349 ""]2350 expected = [2351 " int foo() {",2352 " x;",2353 "#ifdef FLA",2354 ""]2355 self.setOrigin(origin)2356 self.setCursorPosition(1,6);2357 self.enter();2358 self.type("#");2359 self.type("ifdef FLA");2360 self.verifyExpected(expected)2361 def test_prep2(self):2362 origin = [2363 " int foo() {",2364 " x;",2365 "#ifdef FLA",2366 ""]2367 expected = [2368 " int foo() {",2369 " x;",2370 "#ifdef FLA",2371 " ok",2372 ""]2373 self.setOrigin(origin)2374 self.setCursorPosition(2,10);2375 self.enter();2376 self.type("ok");2377 self.verifyExpected(expected)2378 """FIXME probably, old tests. Now preprocessor is indented2379 def test_prep3(self):2380 origin = [2381 " int foo() {",2382 " x;",2383 ""]2384 expected = [2385 " int foo() {",2386 " x;",2387 " #region FLA",2388 ""]2389 self.setOrigin(origin)2390 self.setCursorPosition(1,6);2391 self.enter();2392 self.type("#region FLA");2393 self.verifyExpected(expected)2394 def test_prep4(self):2395 origin = [2396 " int foo() {",2397 " x;",2398 ""]2399 expected = [2400 " int foo() {",2401 " x;",2402 " #endregion FLA",2403 ""]2404 self.setOrigin(origin)2405 self.setCursorPosition(1,6);2406 self.enter();2407 self.type("#endregion FLA");2408 self.verifyExpected(expected)2409 """2410 def test_prep5(self):2411 origin = [2412 " int foo() {",2413 " x;",2414 "#endregion FLA",2415 ""]2416 expected = [2417 " int foo() {",2418 " x;",2419 "#endregion FLA // n",2420 ""]2421 self.setOrigin(origin)2422 self.setCursorPosition(2,14);2423 self.type(" // n");2424 self.verifyExpected(expected)2425 def test_prep6(self):2426 origin = [2427 " int foo() {",2428 " x;",2429 "#endregion",2430 ""]2431 expected = [2432 " int foo() {",2433 " x;",2434 "#endregion daten",2435 ""]2436 self.setOrigin(origin)2437 self.setCursorPosition(2,10);2438 self.type(" daten");2439 self.verifyExpected(expected)2440class Forein(BaseTestClass):2441 def test_foreign1(self):2442 origin = [2443 "// indent-width is 2 but we want to maintain an indentation of 4",2444 "int main() {",2445 ""]2446 expected = [2447 "// indent-width is 2 but we want to maintain an indentation of 4",2448 "int main() {",2449 " bla();",2450 ""]2451 self.setOrigin(origin)2452 self.setCursorPosition(1,12);2453 self.enter();2454 self.type(" bla();");2455 self.verifyExpected(expected)2456 def test_foreign2(self):2457 origin = [2458 "// indent-width is 2 but we want to maintain an indentation of 4",2459 "int main() {",2460 " bla;",2461 ""]2462 expected = [2463 "// indent-width is 2 but we want to maintain an indentation of 4",2464 "int main() {",2465 " bla;",2466 " bli();",2467 ""]2468 self.setOrigin(origin)2469 self.setCursorPosition(2,8);2470 self.enter();2471 self.type("bli();");2472 self.verifyExpected(expected)2473 def test_foreign3(self):2474 origin = [2475 "int main() {",2476 "// indent-width is 2 but we want to maintain an indentation of 4",2477 ""]2478 expected = [2479 "int main() {",2480 " ok",2481 "// indent-width is 2 but we want to maintain an indentation of 4",2482 ""]2483 self.setOrigin(origin)2484 self.setCursorPosition(0,12);2485 self.enter();2486 self.type(" ok");2487 self.verifyExpected(expected)2488class Other(BaseTestClass):2489 def test_alignbrace(self):2490 origin = [2491 " if ( true ) {",2492 " ",2493 "}",2494 ""]2495 expected = [2496 " if ( true ) {",2497 " ",2498 " }",2499 ""]2500 self.setOrigin(origin)2501 self.setCursorPosition(2,0);2502 self.alignLine(2)2503 self.verifyExpected(expected)2504 def test_137157(self):2505 origin = [2506 "# 1",2507 "do {",2508 "}",2509 " while (0);",2510 " "]2511 expected = [2512 "# 1",2513 "do {",2514 "}",2515 " while (0);",2516 " ",2517 " ok"]2518 self.setOrigin(origin)2519 self.setCursorPosition(4,1);2520 self.enter();2521 self.type("ok");2522 self.verifyExpected(expected)2523if __name__ == '__main__':...

Full Screen

Full Screen

hterm_screen_tests.js

Source:hterm_screen_tests.js Github

copy

Full Screen

...95 ary[i] = document.createElement('div');96 ary[i].textContent = i;97 this.screen.pushRow(ary[i]);98 }99 this.screen.setCursorPosition(0, 0);100 result.assertEQ(this.screen.cursorRowNode_, ary[0]);101 result.assertEQ(this.screen.cursorNode_, ary[0].firstChild);102 result.assertEQ(this.screen.cursorOffset_, 0);103 this.screen.setCursorPosition(1, 0);104 result.assertEQ(this.screen.cursorRowNode_, ary[1]);105 result.assertEQ(this.screen.cursorNode_, ary[1].firstChild);106 result.assertEQ(this.screen.cursorOffset_, 0);107 this.screen.setCursorPosition(1, 10);108 result.assertEQ(this.screen.cursorRowNode_, ary[1]);109 result.assertEQ(this.screen.cursorNode_, ary[1].firstChild);110 result.assertEQ(this.screen.cursorOffset_, 10);111 this.screen.setCursorPosition(1, 5);112 result.assertEQ(this.screen.cursorRowNode_, ary[1]);113 result.assertEQ(this.screen.cursorNode_, ary[1].firstChild);114 result.assertEQ(this.screen.cursorOffset_, 5);115 this.screen.setCursorPosition(1, 10);116 result.assertEQ(this.screen.cursorRowNode_, ary[1]);117 result.assertEQ(this.screen.cursorNode_, ary[1].firstChild);118 result.assertEQ(this.screen.cursorOffset_, 10);119 ary[2].innerHTML = '01<div>23</div>45<div>67</div>89';120 this.screen.setCursorPosition(2, 0);121 result.assertEQ(this.screen.cursorRowNode_, ary[2]);122 result.assertEQ(this.screen.cursorNode_, ary[2].firstChild);123 result.assertEQ(this.screen.cursorOffset_, 0);124 this.screen.setCursorPosition(2, 1);125 result.assertEQ(this.screen.cursorRowNode_, ary[2]);126 result.assertEQ(this.screen.cursorNode_, ary[2].firstChild);127 result.assertEQ(this.screen.cursorOffset_, 1);128 this.screen.setCursorPosition(2, 2);129 result.assertEQ(this.screen.cursorRowNode_, ary[2]);130 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[1]);131 result.assertEQ(this.screen.cursorOffset_, 0);132 this.screen.setCursorPosition(2, 3);133 result.assertEQ(this.screen.cursorRowNode_, ary[2]);134 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[1]);135 result.assertEQ(this.screen.cursorOffset_, 1);136 this.screen.setCursorPosition(2, 4);137 result.assertEQ(this.screen.cursorRowNode_, ary[2]);138 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[2]);139 result.assertEQ(this.screen.cursorOffset_, 0);140 this.screen.setCursorPosition(2, 5);141 result.assertEQ(this.screen.cursorRowNode_, ary[2]);142 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[2]);143 result.assertEQ(this.screen.cursorOffset_, 1);144 this.screen.setCursorPosition(2, 6);145 result.assertEQ(this.screen.cursorRowNode_, ary[2]);146 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[3]);147 result.assertEQ(this.screen.cursorOffset_, 0);148 this.screen.setCursorPosition(2, 7);149 result.assertEQ(this.screen.cursorRowNode_, ary[2]);150 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[3]);151 result.assertEQ(this.screen.cursorOffset_, 1);152 this.screen.setCursorPosition(2, 8);153 result.assertEQ(this.screen.cursorRowNode_, ary[2]);154 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[4]);155 result.assertEQ(this.screen.cursorOffset_, 0);156 this.screen.setCursorPosition(2, 9);157 result.assertEQ(this.screen.cursorRowNode_, ary[2]);158 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[4]);159 result.assertEQ(this.screen.cursorOffset_, 1);160 this.screen.setCursorPosition(2, 18);161 result.assertEQ(this.screen.cursorRowNode_, ary[2]);162 result.assertEQ(this.screen.cursorNode_, ary[2].childNodes[4]);163 result.assertEQ(this.screen.cursorOffset_, 10);164 result.pass();165 });166/**167 * Test character removal.168 */169hterm.Screen.Tests.addTest('delete-chars', function(result, cx) {170 var row = document.createElement('div');171 row.innerHTML = 'hello<div id="1"> </div><div id="2">world</div>';172 this.screen.pushRow(row);173 this.screen.setCursorPosition(0, 3);174 this.screen.deleteChars(5);175 result.assertEQ(row.innerHTML, 'hel<div id="2">rld</div>');176 var createWidecharNode = function(c) {177 var span = document.createElement('span');178 span.textContent = c;179 span.className = 'wc-node';180 span.wcNode = true;181 return span;182 };183 var wc_row = document.createElement('div');184 wc_row.appendChild(createWidecharNode('\u4E2D'));185 wc_row.appendChild(createWidecharNode('\u6587'));186 wc_row.appendChild(createWidecharNode('\u5B57'));187 wc_row.appendChild(createWidecharNode('\u4E32'));188 this.screen.pushRow(wc_row);189 this.screen.setCursorPosition(1, 2);190 this.screen.deleteChars(2);191 result.assertEQ(wc_row.innerHTML, '<span class="wc-node">\u4E2D</span>' +192 '<span class="wc-node">\u5B57</span>' +193 '<span class="wc-node">\u4E32</span>');194 this.screen.setCursorPosition(1, 0);195 this.screen.deleteChars(6);196 result.assertEQ(wc_row.innerHTML, '');197 result.pass();198 });199/**200 * Test the ability to insert text in a line.201 */202hterm.Screen.Tests.addTest('insert', function(result, cx) {203 // Sample rows. Row 0 is a simple, empty row. Row 1 simulates rows with204 // mixed text attributes.205 var ary = [document.createElement('div'), document.createElement('div'),206 document.createElement('div')];207 ary[1].innerHTML = 'hello<div id="1"> </div><div id="2">world</div>';208 this.screen.pushRows(ary);209 // Basic insert.210 this.screen.setCursorPosition(0, 0);211 this.screen.insertString('XXXXX');212 result.assertEQ(ary[0].innerHTML, 'XXXXX');213 // Test that positioning the cursor beyond the end of the current text does214 // not cause spaces to be printed.215 this.screen.clearCursorRow();216 this.screen.setCursorPosition(0, 3);217 result.assertEQ(ary[0].innerHTML, '');218 // Print some text at this cursor position and make sure the spaces show up.219 this.screen.insertString('XXXXX');220 result.assertEQ(ary[0].innerHTML, ' XXXXX');221 // Fetch enough whitespace to ensure that the row is full.222 var ws = lib.f.getWhitespace(this.screen.getWidth());223 // Check text clipping and cursor clamping.224 this.screen.clearCursorRow();225 this.screen.insertString('XXXX');226 this.screen.setCursorPosition(0, 2);227 this.screen.insertString(ws);228 this.screen.maybeClipCurrentRow();229 result.assertEQ(ary[0].innerHTML, 'XX' + ws.substr(2));230 result.assertEQ(this.screen.cursorPosition.column, 79);231 // Insert into a more complicated row.232 this.screen.setCursorPosition(1, 3);233 this.screen.insertString('XXXXX');234 result.assertEQ(ary[1].innerHTML, 'helXXXXXlo<div id="1"> </div>' +235 '<div id="2">world</div>');236 // Test inserting widechar string.237 var wideCharString = '\u4E2D\u6587\u5B57\u4E32';238 this.screen.setCursorPosition(2, 0);239 this.screen.textAttributes.wcNode = true;240 for (var i = 0; i < wideCharString.length; i++) {241 this.screen.insertString(wideCharString.charAt(i));242 }243 this.screen.textAttributes.wcNode = false;244 result.assertEQ(ary[2].innerHTML, '<span class="wc-node">\u4E2D</span>' +245 '<span class="wc-node">\u6587</span>' +246 '<span class="wc-node">\u5B57</span>' +247 '<span class="wc-node">\u4E32</span>');248 this.screen.clearCursorRow();249 this.screen.setCursorPosition(2, 3);250 this.screen.textAttributes.wcNode = true;251 for (var i = 0; i < wideCharString.length; i++) {252 this.screen.insertString(wideCharString.charAt(i));253 }254 this.screen.textAttributes.wcNode = false;255 result.assertEQ(ary[2].innerHTML, ' <span class="wc-node">\u4E2D</span>' +256 '<span class="wc-node">\u6587</span>' +257 '<span class="wc-node">\u5B57</span>' +258 '<span class="wc-node">\u4E32</span>');259 this.screen.setCursorPosition(2, 7);260 this.screen.insertString('XXXXX');261 result.assertEQ(ary[2].innerHTML, ' <span class="wc-node">\u4E2D</span>' +262 '<span class="wc-node">\u6587</span>' + 'XXXXX' +263 '<span class="wc-node">\u5B57</span>' +264 '<span class="wc-node">\u4E32</span>');265 this.screen.clearCursorRow();266 this.screen.insertString('XXXXX');267 this.screen.setCursorPosition(2, 3);268 this.screen.textAttributes.wcNode = true;269 for (var i = 0; i < wideCharString.length; i++) {270 this.screen.insertString(wideCharString.charAt(i));271 }272 this.screen.textAttributes.wcNode = false;273 result.assertEQ(ary[2].innerHTML, 'XXX<span class="wc-node">\u4E2D</span>' +274 '<span class="wc-node">\u6587</span>' +275 '<span class="wc-node">\u5B57</span>' +276 '<span class="wc-node">\u4E32</span>XX');277 result.pass();278 });279/**280 * Test the ability to overwrite test.281 */282hterm.Screen.Tests.addTest('overwrite', function(result, cx) {283 var ary = [];284 ary[0] = document.createElement('div');285 ary[0].innerHTML = 'hello<div id="1"> </div><div id="2">world</div>';286 ary[1] = document.createElement('div');287 ary[2] = document.createElement('div');288 this.screen.pushRows(ary);289 this.screen.setCursorPosition(0, 3);290 this.screen.overwriteString('XXXXX');291 result.assertEQ(ary[0].innerHTML, 'helXXXXX<div id="2">rld</div>');292 this.screen.setCursorPosition(1, 0);293 this.screen.overwriteString('XXXXX');294 result.assertEQ(ary[1].innerHTML, 'XXXXX');295 // Test overwritting widechar string.296 var wideCharString = '\u4E2D\u6587\u5B57\u4E32';297 this.screen.setCursorPosition(2, 0);298 this.screen.textAttributes.wcNode = true;299 for (var i = 0; i < wideCharString.length; i++) {300 this.screen.overwriteString(wideCharString.charAt(i));301 }302 this.screen.textAttributes.wcNode = false;303 result.assertEQ(ary[2].innerHTML, '<span class="wc-node">\u4E2D</span>' +304 '<span class="wc-node">\u6587</span>' +305 '<span class="wc-node">\u5B57</span>' +306 '<span class="wc-node">\u4E32</span>');307 this.screen.clearCursorRow();308 this.screen.insertString('XXXXX');309 this.screen.setCursorPosition(2, 3);310 this.screen.textAttributes.wcNode = true;311 for (var i = 0; i < wideCharString.length; i++) {312 this.screen.overwriteString(wideCharString.charAt(i));313 }314 this.screen.textAttributes.wcNode = false;315 result.assertEQ(ary[2].innerHTML, 'XXX<span class="wc-node">\u4E2D</span>' +316 '<span class="wc-node">\u6587</span>' +317 '<span class="wc-node">\u5B57</span>' +318 '<span class="wc-node">\u4E32</span>');319 this.screen.setCursorPosition(2, 7);320 this.screen.overwriteString('OO');321 result.assertEQ(ary[2].innerHTML, 'XXX<span class="wc-node">\u4E2D</span>' +322 '<span class="wc-node">\u6587</span>' + 'OO' +323 '<span class="wc-node">\u4E32</span>');324 this.screen.clearCursorRow();325 this.screen.textAttributes.wcNode = true;326 for (var i = 0; i < wideCharString.length; i++) {327 this.screen.insertString(wideCharString.charAt(i));328 }329 this.screen.textAttributes.wcNode = false;330 this.screen.setCursorPosition(2, 4);331 this.screen.textAttributes.wcNode = true;332 for (var i = 0; i < wideCharString.length; i++) {333 this.screen.overwriteString(wideCharString.charAt(i));334 }335 this.screen.textAttributes.wcNode = false;336 result.assertEQ(ary[2].innerHTML, '<span class="wc-node">\u4E2D</span>' +337 '<span class="wc-node">\u6587</span>' +338 '<span class="wc-node">\u4E2D</span>' +339 '<span class="wc-node">\u6587</span>' +340 '<span class="wc-node">\u5B57</span>' +341 '<span class="wc-node">\u4E32</span>');342 this.screen.clearCursorRow();343 this.screen.textAttributes.wcNode = true;344 for (var i = 0; i < wideCharString.length; i++) {345 this.screen.insertString(wideCharString.charAt(i));346 }347 this.screen.textAttributes.wcNode = false;348 this.screen.setCursorPosition(2, 0);349 this.screen.overwriteString(' ');350 result.assertEQ(ary[2].innerHTML, ' ' +351 '<span class="wc-node">\u5B57</span>' +352 '<span class="wc-node">\u4E32</span>');353 result.pass();...

Full Screen

Full Screen

mask.js

Source:mask.js Github

copy

Full Screen

...10 $('#' + field).val('');11 }12 if (tamStr==1) {13 $('#' + field).val(cpf + ' . . -');14 $('#' + field).setCursorPosition(1);15 } 16 if (tamStr==2) {17 $('#' + field).val(cpf + ' . . -');18 $('#' + field).setCursorPosition(2);19 }20 if (tamStr==3) {21 $('#' + field).val(cpf + '. . -');22 $('#' + field).setCursorPosition(3);23 }24 if (tamStr==4) {25 $('#' + field).val(cpf.substr(0, 3) + '.' + cpf.substr(-1) + ' . -');26 $('#' + field).setCursorPosition(5);27 }28 if (tamStr==5) {29 $('#' + field).val(cpf.substr(0, 3) + '.' + cpf.substr(-2) + ' . -');30 $('#' + field).setCursorPosition(6);31 }32 if (tamStr==6) {33 $('#' + field).val(cpf.substr(0, 3) + '.' + cpf.substr(-3) + '. -');34 $('#' + field).setCursorPosition(7);35 }36 if (tamStr==7) {37 $('#' + field).val(cpf.substr(0, 3) + '.' + cpf.substr(3, 3) + '.' + cpf.substr(-1) + ' -');38 $('#' + field).setCursorPosition(9);39 }40 if (tamStr==8) {41 $('#' + field).val(cpf.substr(0, 3) + '.' + cpf.substr(3, 3) + '.' + cpf.substr(-2) + ' -');42 $('#' + field).setCursorPosition(10);43 }44 if (tamStr==9) {45 $('#' + field).val(cpf.substr(0, 3) + '.' + cpf.substr(3, 3) + '.' + cpf.substr(-3) + '-');46 $('#' + field).setCursorPosition(11);47 }48 if (tamStr==10) {49 $('#' + field).val(cpf.substr(0, 3) + '.' + cpf.substr(3, 3) + '.' + cpf.substr(6, 3) + '-' + cpf.substr(-1));50 $('#' + field).setCursorPosition(13);51 }52 if (tamStr==11) {53 $('#' + field).val(cpf.substr(0, 3) + '.' + cpf.substr(3, 3) + '.' + cpf.substr(6, 3) + '-' + cpf.substr(-2));54 $('#' + field).setCursorPosition(14);55 }56 if (tamStr==12) {57 $('#' + field).val(cpf.substr(0, 2) + '.' + cpf.substr(2, 3) + '.' + cpf.substr(5, 3) + '/' + cpf.substr(-4) + '-');58 $('#' + field).setCursorPosition(15);59 }60 if (tamStr==13) {61 $('#' + field).val(cpf.substr(0, 2) + '.' + cpf.substr(2, 3) + '.' + cpf.substr(5, 3) + '/' + cpf.substr(8, 4) + '-' + cpf.substr(-1));62 $('#' + field).setCursorPosition(17);63 }64 if (tamStr>=14) {65 $('#' + field).val(cpf.substr(0, 2) + '.' + cpf.substr(2, 3) + '.' + cpf.substr(5, 3) + '/' + cpf.substr(8, 4) + '-' + cpf.substr(12,2));66 $('#' + field).setCursorPosition(18);67 }68}69function telmask(field){70 var tel = $('#' + field).val();71 tel = tel.replace(/[^0-9]/gi, '');72 var tamStr = tel.length;73 if (tamStr==0) {74 $('#' + field).val('');75 }76 if (tamStr==1) {77 $('#' + field).val('(' + tel + ')-');78 $('#' + field).setCursorPosition(2);79 }80 if (tamStr==2) {81 $('#' + field).val('(' + tel + ')-');82 $('#' + field).setCursorPosition(3);83 }84 if (tamStr==3) {85 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(-1) + '-');86 $('#' + field).setCursorPosition(5);87 }88 if (tamStr==4) {89 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(-2) + '-');90 $('#' + field).setCursorPosition(6);91 }92 if (tamStr==5) {93 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(-3) + '-');94 $('#' + field).setCursorPosition(7);95 }96 if (tamStr==6) {97 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(-4) + '-');98 $('#' + field).setCursorPosition(8);99 }100 if (tamStr==7) {101 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(2, 4) + '-' + tel.substr(-1));102 $('#' + field).setCursorPosition(10);103 }104 if (tamStr==8) {105 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(2, 4) + '-' + tel.substr(-2));106 $('#' + field).setCursorPosition(11);107 }108 if (tamStr==9) {109 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(2, 4) + '-' + tel.substr(-3));110 $('#' + field).setCursorPosition(12);111 }112 if (tamStr==10) {113 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(2, 4) + '-' + tel.substr(-4));114 $('#' + field).setCursorPosition(13);115 }116 if (tamStr>=11) {117 $('#' + field).val('(' + tel.substr(0, 2) + ')' + tel.substr(2, 5) + '-' + tel.substr(7,4));118 $('#' + field).setCursorPosition(14);119 }120}121function cepmask(field){122 var cep = $('#' + field).val();123 cep = cep.replace(/[^0-9]/gi, '');124 var tamStr = cep.length;125 if (tamStr==0) {126 $('#' + field).val('');127 }128 if (tamStr==1) {129 $('#' + field).val(cep + ' -');130 $('#' + field).setCursorPosition(1);131 }132 if (tamStr==2) {133 $('#' + field).val(cep + ' -');134 $('#' + field).setCursorPosition(2);135 }136 if (tamStr==3) {137 $('#' + field).val(cep + ' -');138 $('#' + field).setCursorPosition(3);139 }140 if (tamStr==4) {141 $('#' + field).val(cep + ' -');142 $('#' + field).setCursorPosition(4);143 }144 if (tamStr==5) {145 $('#' + field).val(cep + '-');146 $('#' + field).setCursorPosition(5);147 }148 if (tamStr==6) {149 $('#' + field).val(cep.substr(0, 5) + '-' + cep.substr(-1));150 $('#' + field).setCursorPosition(7);151 }152 if (tamStr==7) {153 $('#' + field).val(cep.substr(0, 5) + '-' + cep.substr(-2));154 $('#' + field).setCursorPosition(8);155 }156 if (tamStr>=8) {157 $('#' + field).val(cep.substr(0, 5) + '-' + cep.substr(5, 3));158 $('#' + field).setCursorPosition(9);159 }160}161//SET CURSOR POSITION162$.fn.setCursorPosition = function(pos) {163 this.each(function(index, elem) {164 if (elem.setSelectionRange) {165 elem.setSelectionRange(pos, pos);166 } else if (elem.createTextRange) {167 var range = elem.createTextRange();168 range.collapse(true);169 range.moveEnd('character', pos);170 range.moveStart('character', pos);171 range.select();172 }...

Full Screen

Full Screen

test_python.py

Source:test_python.py Github

copy

Full Screen

...22 "def some_function():",23 " return",24 "pass"]25 self.setOrigin(origin)26 self.setCursorPosition(1, 11)27 self.enter()28 self.type("pass")29 self.verifyExpected(expected)30 def test_dedentContinue(self):31 origin = [32 "while True:",33 " continue"]34 expected = [35 "while True:",36 " continue",37 "pass"]38 self.setOrigin(origin)39 self.setCursorPosition(1, 11)40 self.enter()41 self.type("pass")42 self.verifyExpected(expected)43 def test_keepIndent2(self):44 origin = [45 "class my_class():",46 " def my_fun():",47 ' print "Foo"',48 " print 3"]49 expected = [50 "class my_class():",51 " def my_fun():",52 ' print "Foo"',53 " print 3",54 " pass"]55 self.setOrigin(origin)56 self.setCursorPosition(3, 12)57 self.enter()58 self.type("pass")59 self.verifyExpected(expected)60 def test_keepIndent4(self):61 origin = [62 "def some_function():"]63 expected = [64 "def some_function():",65 " pass",66 "",67 "pass"]68 self.setOrigin(origin)69 self.setCursorPosition(0, 22)70 self.enter()71 self.type("pass")72 self.enter()73 self.enter()74 self.type("pass")75 self.verifyExpected(expected)76 def test_dedentRaise(self):77 origin = [78 "try:",79 " raise"]80 expected = [81 "try:",82 " raise",83 "except:"]84 self.setOrigin(origin)85 self.setCursorPosition(1, 9)86 self.enter()87 self.type("except:")88 self.verifyExpected(expected)89 def test_indentColon1(self):90 origin = [91 "def some_function(param, param2):"]92 expected = [93 "def some_function(param, param2):",94 " pass"]95 self.setOrigin(origin)96 self.setCursorPosition(0, 34)97 self.enter()98 self.type("pass")99 self.verifyExpected(expected)100 def test_indentColon2(self):101 origin = [102 "def some_function(1,",103 " 2):"104 ]105 expected = [106 "def some_function(1,",107 " 2):",108 " pass"109 ]110 self.setOrigin(origin)111 self.setCursorPosition(1, 21)112 self.enter()113 self.type("pass")114 self.verifyExpected(expected)115 def test_indentColon3(self):116 """Do not indent colon if hanging indentation used117 """118 origin = [119 " a = {1:"120 ]121 expected = [122 " a = {1:",123 " x"124 ]125 self.setOrigin(origin)126 self.setCursorPosition(0, 12)127 self.enter()128 self.type("x")129 self.verifyExpected(expected)130 def test_dedentPass(self):131 origin = [132 "def some_function():",133 " pass"]134 expected = [135 "def some_function():",136 " pass",137 "pass"]138 self.setOrigin(origin)139 self.setCursorPosition(1, 8)140 self.enter()141 self.type("pass")142 self.verifyExpected(expected)143 def test_dedentBreak(self):144 origin = [145 "def some_function():",146 " return"]147 expected = [148 "def some_function():",149 " return",150 "pass"]151 self.setOrigin(origin)152 self.setCursorPosition(1, 11)153 self.enter()154 self.type("pass")155 self.verifyExpected(expected)156 def test_keepIndent3(self):157 origin = [158 "while True:",159 " returnFunc()",160 " myVar = 3"]161 expected = [162 "while True:",163 " returnFunc()",164 " myVar = 3",165 " pass"]166 self.setOrigin(origin)167 self.setCursorPosition(2, 12)168 self.enter()169 self.type("pass")170 self.verifyExpected(expected)171 def test_keepIndent1(self):172 origin = [173 "def some_function(param, param2):",174 " a = 5",175 " b = 7"]176 expected = [177 "def some_function(param, param2):",178 " a = 5",179 " b = 7",180 " pass"]181 self.setOrigin(origin)182 self.setCursorPosition(2, 8)183 self.enter()184 self.type("pass")185 self.verifyExpected(expected)186 def test_autoIndentAfterEmpty(self):187 origin = [188 "while True:",189 " returnFunc()",190 "",191 " myVar = 3"]192 expected = [193 "while True:",194 " returnFunc()",195 "",196 " x",197 " myVar = 3"]198 self.setOrigin(origin)199 self.setCursorPosition(2, 0)200 self.enter()201 self.tab()202 self.type("x")203 self.verifyExpected(expected)204 def test_hangingIndentation(self):205 origin = [206 " return func (something,",207 ]208 expected = [209 " return func (something,",210 " x",211 ]212 self.setOrigin(origin)213 self.setCursorPosition(0, 28)214 self.enter()215 self.type("x")216 self.verifyExpected(expected)217 def test_hangingIndentation2(self):218 origin = [219 " return func (",220 " something,",221 ]222 expected = [223 " return func (",224 " something,",225 " x",226 ]227 self.setOrigin(origin)228 self.setCursorPosition(1, 19)229 self.enter()230 self.type("x")231 self.verifyExpected(expected)232 def test_hangingIndentation3(self):233 origin = [234 " a = func (",235 " something)",236 ]237 expected = [238 " a = func (",239 " something)",240 " x",241 ]242 self.setOrigin(origin)243 self.setCursorPosition(1, 19)244 self.enter()245 self.type("x")246 self.verifyExpected(expected)247 def test_hangingIndentation4(self):248 origin = [249 " return func(a,",250 " another_func(1,",251 " 2),",252 ]253 expected = [254 " return func(a,",255 " another_func(1,",256 " 2),",257 " x"258 ]259 self.setOrigin(origin)260 self.setCursorPosition(2, 33)261 self.enter()262 self.type("x")263 self.verifyExpected(expected)264 def test_hangingIndentation5(self):265 origin = [266 " return func(another_func(1,",267 " 2),",268 ]269 expected = [270 " return func(another_func(1,",271 " 2),",272 " x"273 ]274 self.setOrigin(origin)275 self.setCursorPosition(2, 33)276 self.enter()277 self.type("x")278 self.verifyExpected(expected)279if __name__ == '__main__':...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { setCursorPosition } = require("qawolf");2await setCursorPosition(page, "#input", 0, 0);3const { setCursorPosition } = require("qawolf");4await setCursorPosition(page, "#input", 0, 0);5const { setCursorPosition } = require("qawolf");6await setCursorPosition(page, "#input", 0, 0);7const { setCursorPosition } = require("qawolf");8await setCursorPosition(page, "#input", 0, 0);9const { setCursorPosition } = require("qawolf");10await setCursorPosition(page, "#input", 0, 0);11const { setCursorPosition } = require("qawolf");12await setCursorPosition(page, "#input", 0, 0);13const { setCursorPosition } = require("qawolf");14await setCursorPosition(page, "#input", 0, 0);15const { setCursorPosition } = require("qawolf");16await setCursorPosition(page, "#input", 0, 0);17const { setCursorPosition } = require("qawolf");18await setCursorPosition(page, "#input", 0, 0);19const { setCursorPosition } = require("qawolf");20await setCursorPosition(page, "#input", 0, 0);21const { setCursorPosition } = require("qawolf");22await setCursorPosition(page, "#input", 0, 0);23const { setCursorPosition } = require("qawolf");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { setCursorPosition } = require("qawolf");2await setCursorPosition(page, "input[name='q']", { x: 0, y: 0 });3await page.mouse.move(0, 0);4await page.mouse.move(0, 0);5 .hover('input[name="q"]')6 .click('input[name="q"]')7 .pressKey("home");8await browser.execute(function() {9 document.querySelector('input[name="q"]').setSelectionRange(0, 0);10});11await browser.execute(function() {12 document.querySelector('input[name="q"]').setSelectionRange(0, 0);13});14await browser.execute(function() {15 document.querySelector('input[name="q"]').setSelectionRange(0, 0);16});17await browser.execute(function() {18 document.querySelector('input[name="q"]').setSelectionRange(0, 0);19});20const { setCursorPositionByElement } = require("qawolf");21await setCursorPositionByElement(

Full Screen

Using AI Code Generation

copy

Full Screen

1const { setCursorPosition } = require("qawolf");2module.exports = async function() {3 await setCursorPosition(0, 0);4};5const { launch, setCursorPosition } = require("qawolf");6describe("test", () => {7 let browser;8 beforeAll(async () => {9 browser = await launch();10 });11 afterAll(async () => {12 await browser.close();13 });14 it("test", async () => {15 const page = await browser.newPage();16 await setCursorPosition(page, 0, 0);17 });18});

Full Screen

Using AI Code Generation

copy

Full Screen

1await setCursorPosition("input[name='email']", 5);2await page.evaluate((selector, position) => {3 const input = document.querySelector(selector);4 if (input) {5 input.focus();6 input.setSelectionRange(position, position);7 }8}, "input[name='email']", 5);9await page.evaluate((selector, position) => {10 const input = document.querySelector(selector);11 if (input) {12 input.focus();13 input.setSelectionRange(position, position);14 }15}, "input[name='email']", 5);16await page.evaluate((selector, position) => {17 const input = document.querySelector(selector);18 if (input) {19 input.focus();20 input.setSelectionRange(position, position);21 }22}, "input[name='email']", 5);23await page.evaluate((selector, position) => {24 const input = document.querySelector(selector);25 if (input) {26 input.focus();27 input.setSelectionRange(position, position);28 }29}, "input[name='email']", 5);30await page.evaluate((selector, position) => {31 const input = document.querySelector(selector);32 if (input) {33 input.focus();34 input.setSelectionRange(position, position);35 }36}, "input[name='email']", 5);37await page.evaluate((selector, position) => {38 const input = document.querySelector(selector);39 if (input) {40 input.focus();41 input.setSelectionRange(position, position);42 }43}, "input[name='email']", 5);44await page.evaluate((selector, position) => {45 const input = document.querySelector(selector);46 if (input) {47 input.focus();48 input.setSelectionRange(position, position);49 }50}, "input[name='email']", 5);51await page.evaluate((selector, position) => {52 const input = document.querySelector(selector);53 if (input) {54 input.focus();55 input.setSelectionRange(position, position);56 }57}, "input[name='email']", 5);58await page.evaluate((

Full Screen

Using AI Code Generation

copy

Full Screen

1await qawolf.setCursorPosition("#input", 0, 0);2await qawolf.type("#input", "test");3await qawolf.click("#button");4await qawolf.setCursorPosition("#input", 0, 0);5await qawolf.type("#input", "test");6await qawolf.click("#button");7await qawolf.setCursorPosition("#input", 0, 0);8await qawolf.type("#input", "test");9await qawolf.click("#button");10await qawolf.setCursorPosition("#input", 0, 0);11await qawolf.type("#input", "test");12await qawolf.click("#button");13await qawolf.setCursorPosition("#input", 0, 0);14await qawolf.type("#input", "test");15await qawolf.click("#button");16await qawolf.setCursorPosition("#input", 0, 0);17await qawolf.type("#input", "test");18await qawolf.click("#button");19await qawolf.setCursorPosition("#input", 0, 0);20await qawolf.type("#input", "test");21await qawolf.click("#button");22await qawolf.setCursorPosition("#input", 0, 0);23await qawolf.type("#input", "test");24await qawolf.click("#button");25await qawolf.setCursorPosition("#input", 0, 0);26await qawolf.type("#input", "test");27await qawolf.click("#button");28await qawolf.setCursorPosition("#input", 0, 0);29await qawolf.type("#input", "test");

Full Screen

Using AI Code Generation

copy

Full Screen

1await page.evaluate(() => {2window.qawolf.setCursorPosition(100, 100);3});4await page.mouse.click(100, 100);5await page.selectOption('select[name="select1"]', 'Option 1');6await page.selectOption('select[name="select2"]', 'Option 2');7await page.selectOption('select[name="select3"]', 'Option 3');8await page.selectOption('select[name="select4"]', 'Option 4');9await page.selectOption('select[name="select5"]', 'Option 5');10await page.selectOption('select[name="select6"]', 'Option 6');11await page.selectOption('select[name="select7"]', 'Option 7');12await page.selectOption('select[name="select8"]', 'Option 8');13await page.selectOption('select[name="select9"]', 'Option 9');14await page.selectOption('select[name="select10"]', 'Option 10');15await page.selectOption('select[name="select11"]', 'Option 11');16await page.selectOption('select[name="select12"]', 'Option 12');17await page.selectOption('select[name="select13"]', 'Option 13');18await page.selectOption('select[name="select14"]', 'Option 14');19await page.selectOption('select[name="select15"]', 'Option 15');20await page.selectOption('select[name="select16"]', 'Option 16');21await page.selectOption('select[name="select17"]', 'Option 17');22await page.selectOption('select[name="select18"]', 'Option 18');23await page.selectOption('select[name="select19"]', 'Option 19');24await page.selectOption('select[name="select20"]', 'Option 20');25await page.selectOption('select[name="select21"]', 'Option 21');26await page.selectOption('select[name="select22"]', 'Option 22');27await page.selectOption('select[name="select23"]', 'Option 23');28await page.selectOption('select[name="select24"]', 'Option 24');29await page.selectOption('select[name="select25"]', 'Option 25');30await page.selectOption('select[name="select26"]', 'Option 26');31await page.selectOption('select[name="select27"]', 'Option 27');32await page.selectOption('select[name="select28"]

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful