003_cindent_spec.lua 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775
  1. -- Test for 'cindent'.
  2. -- For new tests, consider putting them in test_cindent.vim.
  3. --
  4. -- There are 50+ test command blocks (the stuff between STARTTEST and ENDTEST)
  5. -- in the original test. These have been converted to "it" test cases here.
  6. local helpers = require('test.functional.helpers')(after_each)
  7. local feed, insert = helpers.feed, helpers.insert
  8. local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
  9. -- Inserts text as usual, and additionally positions the cursor on line 1 and
  10. -- sets 'cindent' and tab settings. (In the original "test3.in" the modeline at
  11. -- the top of the file takes care of this.)
  12. local function insert_(content)
  13. insert(content)
  14. feed_command('1', 'set cin ts=4 sw=4')
  15. end
  16. -- luacheck: ignore 621 (Indentation)
  17. -- luacheck: ignore 613 (Trailing whitespace in a string)
  18. describe('cindent', function()
  19. before_each(clear)
  20. it('1 is working', function()
  21. insert_([=[
  22. /* start of AUTO matically checked vim: set ts=4 : */
  23. {
  24. if (test)
  25. cmd1;
  26. cmd2;
  27. }
  28. {
  29. if (test)
  30. cmd1;
  31. else
  32. cmd2;
  33. }
  34. {
  35. if (test)
  36. {
  37. cmd1;
  38. cmd2;
  39. }
  40. }
  41. {
  42. if (test)
  43. {
  44. cmd1;
  45. else
  46. }
  47. }
  48. {
  49. while (this)
  50. if (test)
  51. cmd1;
  52. cmd2;
  53. }
  54. {
  55. while (this)
  56. if (test)
  57. cmd1;
  58. else
  59. cmd2;
  60. }
  61. {
  62. if (test)
  63. {
  64. cmd;
  65. }
  66. if (test)
  67. cmd;
  68. }
  69. {
  70. if (test) {
  71. cmd;
  72. }
  73. if (test) cmd;
  74. }
  75. {
  76. cmd1;
  77. for (blah)
  78. while (this)
  79. if (test)
  80. cmd2;
  81. cmd3;
  82. }
  83. {
  84. cmd1;
  85. for (blah)
  86. while (this)
  87. if (test)
  88. cmd2;
  89. cmd3;
  90. if (test)
  91. {
  92. cmd1;
  93. cmd2;
  94. cmd3;
  95. }
  96. }
  97. /* Test for 'cindent' do/while mixed with if/else: */
  98. {
  99. do
  100. if (asdf)
  101. asdfasd;
  102. while (cond);
  103. do
  104. if (asdf)
  105. while (asdf)
  106. asdf;
  107. while (asdf);
  108. }
  109. /* Test for 'cindent' with two ) on a continuation line */
  110. {
  111. if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
  112. aal;sdkjf ( ;asldfkja;sldfk
  113. al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
  114. line up here;
  115. }
  116. /* C++ tests: */
  117. // foo() these three lines should remain in column 0
  118. // {
  119. // }
  120. /* Test for continuation and unterminated lines: */
  121. {
  122. i = 99 + 14325 +
  123. 21345 +
  124. 21345 +
  125. 21345 + ( 21345 +
  126. 21345) +
  127. 2345 +
  128. 1234;
  129. c = 1;
  130. }
  131. /*
  132. testje for indent with empty line
  133. here */
  134. {
  135. if (testing &&
  136. not a joke ||
  137. line up here)
  138. hay;
  139. if (testing &&
  140. (not a joke || testing
  141. )line up here)
  142. hay;
  143. if (testing &&
  144. (not a joke || testing
  145. line up here))
  146. hay;
  147. }
  148. {
  149. switch (c)
  150. {
  151. case xx:
  152. do
  153. if (asdf)
  154. do
  155. asdfasdf;
  156. while (asdf);
  157. else
  158. asdfasdf;
  159. while (cond);
  160. case yy:
  161. case xx:
  162. case zz:
  163. testing;
  164. }
  165. }
  166. {
  167. if (cond) {
  168. foo;
  169. }
  170. else
  171. {
  172. bar;
  173. }
  174. }
  175. {
  176. if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
  177. alsdkfj (asldk;fj
  178. awith cino=(0 ;lf this one goes to below the paren with ==
  179. ;laksjfd ;lsakdjf ;alskdf asd)
  180. asdfasdf;)))
  181. asdfasdf;
  182. }
  183. int
  184. func(a, b)
  185. int a;
  186. int c;
  187. {
  188. if (c1 && (c2 ||
  189. c3))
  190. foo;
  191. if (c1 &&
  192. (c2 || c3)
  193. )
  194. }
  195. {
  196. while (asd)
  197. {
  198. if (asdf)
  199. if (test)
  200. if (that)
  201. {
  202. if (asdf)
  203. do
  204. cdasd;
  205. while (as
  206. df);
  207. }
  208. else
  209. if (asdf)
  210. asdf;
  211. else
  212. asdf;
  213. asdf;
  214. }
  215. }
  216. {
  217. s = "/*"; b = ';'
  218. s = "/*"; b = ';';
  219. a = b;
  220. }
  221. {
  222. switch (a)
  223. {
  224. case a:
  225. switch (t)
  226. {
  227. case 1:
  228. cmd;
  229. break;
  230. case 2:
  231. cmd;
  232. break;
  233. }
  234. cmd;
  235. break;
  236. case b:
  237. {
  238. int i;
  239. cmd;
  240. }
  241. break;
  242. case c: {
  243. int i;
  244. cmd;
  245. }
  246. case d: if (cond &&
  247. test) { /* this line doesn't work right */
  248. int i;
  249. cmd;
  250. }
  251. break;
  252. }
  253. }
  254. {
  255. if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
  256. (bp_to->b_p_initialized ||
  257. (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
  258. return;
  259. label :
  260. asdf = asdf ?
  261. asdf : asdf;
  262. asdf = asdf ?
  263. asdf: asdf;
  264. }
  265. /* Special Comments : This function has the added complexity (compared */
  266. /* : to addtolist) of having to check for a detail */
  267. /* : texture and add that to the list first. */
  268. char *(array[100]) = {
  269. "testje",
  270. "foo",
  271. "bar",
  272. }
  273. enum soppie
  274. {
  275. yes = 0,
  276. no,
  277. maybe
  278. };
  279. typedef enum soppie
  280. {
  281. yes = 0,
  282. no,
  283. maybe
  284. };
  285. static enum
  286. {
  287. yes = 0,
  288. no,
  289. maybe
  290. } soppie;
  291. public static enum
  292. {
  293. yes = 0,
  294. no,
  295. maybe
  296. } soppie;
  297. static private enum
  298. {
  299. yes = 0,
  300. no,
  301. maybe
  302. } soppie;
  303. {
  304. int a,
  305. b;
  306. }
  307. {
  308. struct Type
  309. {
  310. int i;
  311. char *str;
  312. } var[] =
  313. {
  314. 0, "zero",
  315. 1, "one",
  316. 2, "two",
  317. 3, "three"
  318. };
  319. float matrix[3][3] =
  320. {
  321. {
  322. 0,
  323. 1,
  324. 2
  325. },
  326. {
  327. 3,
  328. 4,
  329. 5
  330. },
  331. {
  332. 6,
  333. 7,
  334. 8
  335. }
  336. };
  337. }
  338. {
  339. /* blah ( blah */
  340. /* where does this go? */
  341. /* blah ( blah */
  342. cmd;
  343. func(arg1,
  344. /* comment */
  345. arg2);
  346. a;
  347. {
  348. b;
  349. {
  350. c; /* Hey, NOW it indents?! */
  351. }
  352. }
  353. {
  354. func(arg1,
  355. arg2,
  356. arg3);
  357. /* Hey, what am I doing here? Is this coz of the ","? */
  358. }
  359. }
  360. main ()
  361. {
  362. if (cond)
  363. {
  364. a = b;
  365. }
  366. if (cond) {
  367. a = c;
  368. }
  369. if (cond)
  370. a = d;
  371. return;
  372. }
  373. {
  374. case 2: if (asdf &&
  375. asdfasdf)
  376. aasdf;
  377. a = 9;
  378. case 3: if (asdf)
  379. aasdf;
  380. a = 9;
  381. case 4: x = 1;
  382. y = 2;
  383. label: if (asdf)
  384. here;
  385. label: if (asdf &&
  386. asdfasdf)
  387. {
  388. }
  389. label: if (asdf &&
  390. asdfasdf) {
  391. there;
  392. }
  393. label: if (asdf &&
  394. asdfasdf)
  395. there;
  396. }
  397. {
  398. /*
  399. hello with ":set comments= cino=c5"
  400. */
  401. /*
  402. hello with ":set comments= cino="
  403. */
  404. }
  405. {
  406. if (a < b) {
  407. a = a + 1;
  408. } else
  409. a = a + 2;
  410. if (a)
  411. do {
  412. testing;
  413. } while (asdfasdf);
  414. a = b + 1;
  415. asdfasdf
  416. }
  417. {
  418. for ( int i = 0;
  419. i < 10; i++ )
  420. {
  421. }
  422. i = 0;
  423. }
  424. class bob
  425. {
  426. int foo() {return 1;}
  427. int bar;
  428. }
  429. main()
  430. {
  431. while(1)
  432. if (foo)
  433. {
  434. bar;
  435. }
  436. else {
  437. asdf;
  438. }
  439. misplacedline;
  440. }
  441. {
  442. if (clipboard.state == SELECT_DONE
  443. && ((row == clipboard.start.lnum
  444. && col >= clipboard.start.col)
  445. || row > clipboard.start.lnum))
  446. }
  447. {
  448. if (1) {i += 4;}
  449. where_am_i;
  450. return 0;
  451. }
  452. {
  453. {
  454. } // sdf(asdf
  455. if (asdf)
  456. asd;
  457. }
  458. {
  459. label1:
  460. label2:
  461. }
  462. {
  463. int fooRet = foo(pBar1, false /*fKB*/,
  464. true /*fPTB*/, 3 /*nT*/, false /*fDF*/);
  465. f() {
  466. for ( i = 0;
  467. i < m;
  468. /* c */ i++ ) {
  469. a = b;
  470. }
  471. }
  472. }
  473. {
  474. f1(/*comment*/);
  475. f2();
  476. }
  477. {
  478. do {
  479. if (foo) {
  480. } else
  481. ;
  482. } while (foo);
  483. foo(); // was wrong
  484. }
  485. int x; // no extra indent because of the ;
  486. void func()
  487. {
  488. }
  489. char *tab[] = {"aaa",
  490. "};", /* }; */ NULL}
  491. int indented;
  492. {}
  493. char *a[] = {"aaa", "bbb",
  494. "ccc", NULL};
  495. // here
  496. char *tab[] = {"aaa",
  497. "xx", /* xx */}; /* asdf */
  498. int not_indented;
  499. {
  500. do {
  501. switch (bla)
  502. {
  503. case 1: if (foo)
  504. bar;
  505. }
  506. } while (boo);
  507. wrong;
  508. }
  509. int foo,
  510. bar;
  511. int foo;
  512. #if defined(foo) \
  513. && defined(bar)
  514. char * xx = "asdf\
  515. foo\
  516. bor";
  517. int x;
  518. char *foo = "asdf\
  519. asdf\
  520. asdf",
  521. *bar;
  522. void f()
  523. {
  524. #if defined(foo) \
  525. && defined(bar)
  526. char *foo = "asdf\
  527. asdf\
  528. asdf",
  529. *bar;
  530. {
  531. int i;
  532. char *foo = "asdf\
  533. asdf\
  534. asdf",
  535. *bar;
  536. }
  537. #endif
  538. }
  539. #endif
  540. int y; // comment
  541. // comment
  542. // comment
  543. {
  544. Constructor(int a,
  545. int b ) : BaseClass(a)
  546. {
  547. }
  548. }
  549. void foo()
  550. {
  551. char one,
  552. two;
  553. struct bla piet,
  554. jan;
  555. enum foo kees,
  556. jannie;
  557. static unsigned sdf,
  558. krap;
  559. unsigned int piet,
  560. jan;
  561. int
  562. kees,
  563. jan;
  564. }
  565. {
  566. t(int f,
  567. int d); // )
  568. d();
  569. }
  570. Constructor::Constructor(int a,
  571. int b
  572. ) :
  573. BaseClass(a,
  574. b,
  575. c),
  576. mMember(b),
  577. {
  578. }
  579. Constructor::Constructor(int a,
  580. int b ) :
  581. BaseClass(a)
  582. {
  583. }
  584. Constructor::Constructor(int a,
  585. int b ) /*x*/ : /*x*/ BaseClass(a),
  586. member(b)
  587. {
  588. }
  589. A::A(int a, int b)
  590. : aa(a),
  591. bb(b),
  592. cc(c)
  593. {
  594. }
  595. class CAbc :
  596. public BaseClass1,
  597. protected BaseClass2
  598. {
  599. int Test() { return FALSE; }
  600. int Test1() { return TRUE; }
  601. CAbc(int a, int b ) :
  602. BaseClass(a)
  603. {
  604. switch(xxx)
  605. {
  606. case abc:
  607. asdf();
  608. break;
  609. case 999:
  610. baer();
  611. break;
  612. }
  613. }
  614. public: // <-- this was incoreectly indented before!!
  615. void testfall();
  616. protected:
  617. void testfall();
  618. };
  619. class CAbc : public BaseClass1,
  620. protected BaseClass2
  621. {
  622. };
  623. static struct
  624. {
  625. int a;
  626. int b;
  627. } variable[COUNT] =
  628. {
  629. {
  630. 123,
  631. 456
  632. },
  633. {
  634. 123,
  635. 456
  636. }
  637. };
  638. static struct
  639. {
  640. int a;
  641. int b;
  642. } variable[COUNT] =
  643. {
  644. { 123, 456 },
  645. { 123, 456 }
  646. };
  647. void asdf() /* ind_maxparen may cause trouble here */
  648. {
  649. if ((0
  650. && 1
  651. && 1
  652. && 1
  653. && 1
  654. && 1
  655. && 1
  656. && 1
  657. && 1
  658. && 1
  659. && 1
  660. && 1
  661. && 1
  662. && 1
  663. && 1
  664. && 1
  665. && 1
  666. && 1
  667. && 1
  668. && 1
  669. && 1
  670. && 1
  671. && 1
  672. && 1
  673. && 1
  674. && 1)) break;
  675. }
  676. foo()
  677. {
  678. a = cond ? foo() : asdf
  679. + asdf;
  680. a = cond ?
  681. foo() : asdf
  682. + asdf;
  683. }
  684. int main(void)
  685. {
  686. if (a)
  687. if (b)
  688. 2;
  689. else 3;
  690. next_line_of_code();
  691. }
  692. barry()
  693. {
  694. Foo::Foo (int one,
  695. int two)
  696. : something(4)
  697. {}
  698. }
  699. barry()
  700. {
  701. Foo::Foo (int one, int two)
  702. : something(4)
  703. {}
  704. }
  705. Constructor::Constructor(int a,
  706. int b
  707. ) :
  708. BaseClass(a,
  709. b,
  710. c),
  711. mMember(b)
  712. {
  713. }
  714. int main ()
  715. {
  716. if (lala)
  717. do
  718. ++(*lolo);
  719. while (lili
  720. && lele);
  721. lulu;
  722. }
  723. int main ()
  724. {
  725. switch (c)
  726. {
  727. case 'c': if (cond)
  728. {
  729. }
  730. }
  731. }
  732. main()
  733. {
  734. (void) MyFancyFuasdfadsfnction(
  735. argument);
  736. }
  737. main()
  738. {
  739. char foo[] = "/*";
  740. /* as
  741. df */
  742. hello
  743. }
  744. /* valid namespaces with normal indent */
  745. namespace
  746. {
  747. {
  748. 111111111111;
  749. }
  750. }
  751. namespace /* test */
  752. {
  753. 11111111111111111;
  754. }
  755. namespace // test
  756. {
  757. 111111111111111111;
  758. }
  759. namespace
  760. {
  761. 111111111111111111;
  762. }
  763. namespace test
  764. {
  765. 111111111111111111;
  766. }
  767. namespace{
  768. 111111111111111111;
  769. }
  770. namespace test{
  771. 111111111111111111;
  772. }
  773. namespace {
  774. 111111111111111111;
  775. }
  776. namespace test {
  777. 111111111111111111;
  778. namespace test2 {
  779. 22222222222222222;
  780. }
  781. }
  782. /* invalid namespaces use block indent */
  783. namespace test test2 {
  784. 111111111111111111111;
  785. }
  786. namespace11111111111 {
  787. 111111111111;
  788. }
  789. namespace() {
  790. 1111111111111;
  791. }
  792. namespace()
  793. {
  794. 111111111111111111;
  795. }
  796. namespace test test2
  797. {
  798. 1111111111111111111;
  799. }
  800. namespace111111111
  801. {
  802. 111111111111111111;
  803. }
  804. void getstring() {
  805. /* Raw strings */
  806. const char* s = R"(
  807. test {
  808. # comment
  809. field: 123
  810. }
  811. )";
  812. }
  813. void getstring() {
  814. const char* s = R"foo(
  815. test {
  816. # comment
  817. field: 123
  818. }
  819. )foo";
  820. }
  821. {
  822. int a[4] = {
  823. [0] = 0,
  824. [1] = 1,
  825. [2] = 2,
  826. [3] = 3,
  827. };
  828. }
  829. {
  830. a = b[2]
  831. + 3;
  832. }
  833. {
  834. if (1)
  835. /* aaaaa
  836. * bbbbb
  837. */
  838. a = 1;
  839. }
  840. void func()
  841. {
  842. switch (foo)
  843. {
  844. case (bar):
  845. if (baz())
  846. quux();
  847. break;
  848. case (shmoo):
  849. if (!bar)
  850. {
  851. }
  852. case (foo1):
  853. switch (bar)
  854. {
  855. case baz:
  856. baz_f();
  857. break;
  858. }
  859. break;
  860. default:
  861. baz();
  862. baz();
  863. break;
  864. }
  865. }
  866. /* end of AUTO */
  867. ]=])
  868. feed_command('/start of AUTO')
  869. feed('=/end of AUTO<cr>')
  870. expect([=[
  871. /* start of AUTO matically checked vim: set ts=4 : */
  872. {
  873. if (test)
  874. cmd1;
  875. cmd2;
  876. }
  877. {
  878. if (test)
  879. cmd1;
  880. else
  881. cmd2;
  882. }
  883. {
  884. if (test)
  885. {
  886. cmd1;
  887. cmd2;
  888. }
  889. }
  890. {
  891. if (test)
  892. {
  893. cmd1;
  894. else
  895. }
  896. }
  897. {
  898. while (this)
  899. if (test)
  900. cmd1;
  901. cmd2;
  902. }
  903. {
  904. while (this)
  905. if (test)
  906. cmd1;
  907. else
  908. cmd2;
  909. }
  910. {
  911. if (test)
  912. {
  913. cmd;
  914. }
  915. if (test)
  916. cmd;
  917. }
  918. {
  919. if (test) {
  920. cmd;
  921. }
  922. if (test) cmd;
  923. }
  924. {
  925. cmd1;
  926. for (blah)
  927. while (this)
  928. if (test)
  929. cmd2;
  930. cmd3;
  931. }
  932. {
  933. cmd1;
  934. for (blah)
  935. while (this)
  936. if (test)
  937. cmd2;
  938. cmd3;
  939. if (test)
  940. {
  941. cmd1;
  942. cmd2;
  943. cmd3;
  944. }
  945. }
  946. /* Test for 'cindent' do/while mixed with if/else: */
  947. {
  948. do
  949. if (asdf)
  950. asdfasd;
  951. while (cond);
  952. do
  953. if (asdf)
  954. while (asdf)
  955. asdf;
  956. while (asdf);
  957. }
  958. /* Test for 'cindent' with two ) on a continuation line */
  959. {
  960. if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
  961. aal;sdkjf ( ;asldfkja;sldfk
  962. al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
  963. line up here;
  964. }
  965. /* C++ tests: */
  966. // foo() these three lines should remain in column 0
  967. // {
  968. // }
  969. /* Test for continuation and unterminated lines: */
  970. {
  971. i = 99 + 14325 +
  972. 21345 +
  973. 21345 +
  974. 21345 + ( 21345 +
  975. 21345) +
  976. 2345 +
  977. 1234;
  978. c = 1;
  979. }
  980. /*
  981. testje for indent with empty line
  982. here */
  983. {
  984. if (testing &&
  985. not a joke ||
  986. line up here)
  987. hay;
  988. if (testing &&
  989. (not a joke || testing
  990. )line up here)
  991. hay;
  992. if (testing &&
  993. (not a joke || testing
  994. line up here))
  995. hay;
  996. }
  997. {
  998. switch (c)
  999. {
  1000. case xx:
  1001. do
  1002. if (asdf)
  1003. do
  1004. asdfasdf;
  1005. while (asdf);
  1006. else
  1007. asdfasdf;
  1008. while (cond);
  1009. case yy:
  1010. case xx:
  1011. case zz:
  1012. testing;
  1013. }
  1014. }
  1015. {
  1016. if (cond) {
  1017. foo;
  1018. }
  1019. else
  1020. {
  1021. bar;
  1022. }
  1023. }
  1024. {
  1025. if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
  1026. alsdkfj (asldk;fj
  1027. awith cino=(0 ;lf this one goes to below the paren with ==
  1028. ;laksjfd ;lsakdjf ;alskdf asd)
  1029. asdfasdf;)))
  1030. asdfasdf;
  1031. }
  1032. int
  1033. func(a, b)
  1034. int a;
  1035. int c;
  1036. {
  1037. if (c1 && (c2 ||
  1038. c3))
  1039. foo;
  1040. if (c1 &&
  1041. (c2 || c3)
  1042. )
  1043. }
  1044. {
  1045. while (asd)
  1046. {
  1047. if (asdf)
  1048. if (test)
  1049. if (that)
  1050. {
  1051. if (asdf)
  1052. do
  1053. cdasd;
  1054. while (as
  1055. df);
  1056. }
  1057. else
  1058. if (asdf)
  1059. asdf;
  1060. else
  1061. asdf;
  1062. asdf;
  1063. }
  1064. }
  1065. {
  1066. s = "/*"; b = ';'
  1067. s = "/*"; b = ';';
  1068. a = b;
  1069. }
  1070. {
  1071. switch (a)
  1072. {
  1073. case a:
  1074. switch (t)
  1075. {
  1076. case 1:
  1077. cmd;
  1078. break;
  1079. case 2:
  1080. cmd;
  1081. break;
  1082. }
  1083. cmd;
  1084. break;
  1085. case b:
  1086. {
  1087. int i;
  1088. cmd;
  1089. }
  1090. break;
  1091. case c: {
  1092. int i;
  1093. cmd;
  1094. }
  1095. case d: if (cond &&
  1096. test) { /* this line doesn't work right */
  1097. int i;
  1098. cmd;
  1099. }
  1100. break;
  1101. }
  1102. }
  1103. {
  1104. if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
  1105. (bp_to->b_p_initialized ||
  1106. (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
  1107. return;
  1108. label :
  1109. asdf = asdf ?
  1110. asdf : asdf;
  1111. asdf = asdf ?
  1112. asdf: asdf;
  1113. }
  1114. /* Special Comments : This function has the added complexity (compared */
  1115. /* : to addtolist) of having to check for a detail */
  1116. /* : texture and add that to the list first. */
  1117. char *(array[100]) = {
  1118. "testje",
  1119. "foo",
  1120. "bar",
  1121. }
  1122. enum soppie
  1123. {
  1124. yes = 0,
  1125. no,
  1126. maybe
  1127. };
  1128. typedef enum soppie
  1129. {
  1130. yes = 0,
  1131. no,
  1132. maybe
  1133. };
  1134. static enum
  1135. {
  1136. yes = 0,
  1137. no,
  1138. maybe
  1139. } soppie;
  1140. public static enum
  1141. {
  1142. yes = 0,
  1143. no,
  1144. maybe
  1145. } soppie;
  1146. static private enum
  1147. {
  1148. yes = 0,
  1149. no,
  1150. maybe
  1151. } soppie;
  1152. {
  1153. int a,
  1154. b;
  1155. }
  1156. {
  1157. struct Type
  1158. {
  1159. int i;
  1160. char *str;
  1161. } var[] =
  1162. {
  1163. 0, "zero",
  1164. 1, "one",
  1165. 2, "two",
  1166. 3, "three"
  1167. };
  1168. float matrix[3][3] =
  1169. {
  1170. {
  1171. 0,
  1172. 1,
  1173. 2
  1174. },
  1175. {
  1176. 3,
  1177. 4,
  1178. 5
  1179. },
  1180. {
  1181. 6,
  1182. 7,
  1183. 8
  1184. }
  1185. };
  1186. }
  1187. {
  1188. /* blah ( blah */
  1189. /* where does this go? */
  1190. /* blah ( blah */
  1191. cmd;
  1192. func(arg1,
  1193. /* comment */
  1194. arg2);
  1195. a;
  1196. {
  1197. b;
  1198. {
  1199. c; /* Hey, NOW it indents?! */
  1200. }
  1201. }
  1202. {
  1203. func(arg1,
  1204. arg2,
  1205. arg3);
  1206. /* Hey, what am I doing here? Is this coz of the ","? */
  1207. }
  1208. }
  1209. main ()
  1210. {
  1211. if (cond)
  1212. {
  1213. a = b;
  1214. }
  1215. if (cond) {
  1216. a = c;
  1217. }
  1218. if (cond)
  1219. a = d;
  1220. return;
  1221. }
  1222. {
  1223. case 2: if (asdf &&
  1224. asdfasdf)
  1225. aasdf;
  1226. a = 9;
  1227. case 3: if (asdf)
  1228. aasdf;
  1229. a = 9;
  1230. case 4: x = 1;
  1231. y = 2;
  1232. label: if (asdf)
  1233. here;
  1234. label: if (asdf &&
  1235. asdfasdf)
  1236. {
  1237. }
  1238. label: if (asdf &&
  1239. asdfasdf) {
  1240. there;
  1241. }
  1242. label: if (asdf &&
  1243. asdfasdf)
  1244. there;
  1245. }
  1246. {
  1247. /*
  1248. hello with ":set comments= cino=c5"
  1249. */
  1250. /*
  1251. hello with ":set comments= cino="
  1252. */
  1253. }
  1254. {
  1255. if (a < b) {
  1256. a = a + 1;
  1257. } else
  1258. a = a + 2;
  1259. if (a)
  1260. do {
  1261. testing;
  1262. } while (asdfasdf);
  1263. a = b + 1;
  1264. asdfasdf
  1265. }
  1266. {
  1267. for ( int i = 0;
  1268. i < 10; i++ )
  1269. {
  1270. }
  1271. i = 0;
  1272. }
  1273. class bob
  1274. {
  1275. int foo() {return 1;}
  1276. int bar;
  1277. }
  1278. main()
  1279. {
  1280. while(1)
  1281. if (foo)
  1282. {
  1283. bar;
  1284. }
  1285. else {
  1286. asdf;
  1287. }
  1288. misplacedline;
  1289. }
  1290. {
  1291. if (clipboard.state == SELECT_DONE
  1292. && ((row == clipboard.start.lnum
  1293. && col >= clipboard.start.col)
  1294. || row > clipboard.start.lnum))
  1295. }
  1296. {
  1297. if (1) {i += 4;}
  1298. where_am_i;
  1299. return 0;
  1300. }
  1301. {
  1302. {
  1303. } // sdf(asdf
  1304. if (asdf)
  1305. asd;
  1306. }
  1307. {
  1308. label1:
  1309. label2:
  1310. }
  1311. {
  1312. int fooRet = foo(pBar1, false /*fKB*/,
  1313. true /*fPTB*/, 3 /*nT*/, false /*fDF*/);
  1314. f() {
  1315. for ( i = 0;
  1316. i < m;
  1317. /* c */ i++ ) {
  1318. a = b;
  1319. }
  1320. }
  1321. }
  1322. {
  1323. f1(/*comment*/);
  1324. f2();
  1325. }
  1326. {
  1327. do {
  1328. if (foo) {
  1329. } else
  1330. ;
  1331. } while (foo);
  1332. foo(); // was wrong
  1333. }
  1334. int x; // no extra indent because of the ;
  1335. void func()
  1336. {
  1337. }
  1338. char *tab[] = {"aaa",
  1339. "};", /* }; */ NULL}
  1340. int indented;
  1341. {}
  1342. char *a[] = {"aaa", "bbb",
  1343. "ccc", NULL};
  1344. // here
  1345. char *tab[] = {"aaa",
  1346. "xx", /* xx */}; /* asdf */
  1347. int not_indented;
  1348. {
  1349. do {
  1350. switch (bla)
  1351. {
  1352. case 1: if (foo)
  1353. bar;
  1354. }
  1355. } while (boo);
  1356. wrong;
  1357. }
  1358. int foo,
  1359. bar;
  1360. int foo;
  1361. #if defined(foo) \
  1362. && defined(bar)
  1363. char * xx = "asdf\
  1364. foo\
  1365. bor";
  1366. int x;
  1367. char *foo = "asdf\
  1368. asdf\
  1369. asdf",
  1370. *bar;
  1371. void f()
  1372. {
  1373. #if defined(foo) \
  1374. && defined(bar)
  1375. char *foo = "asdf\
  1376. asdf\
  1377. asdf",
  1378. *bar;
  1379. {
  1380. int i;
  1381. char *foo = "asdf\
  1382. asdf\
  1383. asdf",
  1384. *bar;
  1385. }
  1386. #endif
  1387. }
  1388. #endif
  1389. int y; // comment
  1390. // comment
  1391. // comment
  1392. {
  1393. Constructor(int a,
  1394. int b ) : BaseClass(a)
  1395. {
  1396. }
  1397. }
  1398. void foo()
  1399. {
  1400. char one,
  1401. two;
  1402. struct bla piet,
  1403. jan;
  1404. enum foo kees,
  1405. jannie;
  1406. static unsigned sdf,
  1407. krap;
  1408. unsigned int piet,
  1409. jan;
  1410. int
  1411. kees,
  1412. jan;
  1413. }
  1414. {
  1415. t(int f,
  1416. int d); // )
  1417. d();
  1418. }
  1419. Constructor::Constructor(int a,
  1420. int b
  1421. ) :
  1422. BaseClass(a,
  1423. b,
  1424. c),
  1425. mMember(b),
  1426. {
  1427. }
  1428. Constructor::Constructor(int a,
  1429. int b ) :
  1430. BaseClass(a)
  1431. {
  1432. }
  1433. Constructor::Constructor(int a,
  1434. int b ) /*x*/ : /*x*/ BaseClass(a),
  1435. member(b)
  1436. {
  1437. }
  1438. A::A(int a, int b)
  1439. : aa(a),
  1440. bb(b),
  1441. cc(c)
  1442. {
  1443. }
  1444. class CAbc :
  1445. public BaseClass1,
  1446. protected BaseClass2
  1447. {
  1448. int Test() { return FALSE; }
  1449. int Test1() { return TRUE; }
  1450. CAbc(int a, int b ) :
  1451. BaseClass(a)
  1452. {
  1453. switch(xxx)
  1454. {
  1455. case abc:
  1456. asdf();
  1457. break;
  1458. case 999:
  1459. baer();
  1460. break;
  1461. }
  1462. }
  1463. public: // <-- this was incoreectly indented before!!
  1464. void testfall();
  1465. protected:
  1466. void testfall();
  1467. };
  1468. class CAbc : public BaseClass1,
  1469. protected BaseClass2
  1470. {
  1471. };
  1472. static struct
  1473. {
  1474. int a;
  1475. int b;
  1476. } variable[COUNT] =
  1477. {
  1478. {
  1479. 123,
  1480. 456
  1481. },
  1482. {
  1483. 123,
  1484. 456
  1485. }
  1486. };
  1487. static struct
  1488. {
  1489. int a;
  1490. int b;
  1491. } variable[COUNT] =
  1492. {
  1493. { 123, 456 },
  1494. { 123, 456 }
  1495. };
  1496. void asdf() /* ind_maxparen may cause trouble here */
  1497. {
  1498. if ((0
  1499. && 1
  1500. && 1
  1501. && 1
  1502. && 1
  1503. && 1
  1504. && 1
  1505. && 1
  1506. && 1
  1507. && 1
  1508. && 1
  1509. && 1
  1510. && 1
  1511. && 1
  1512. && 1
  1513. && 1
  1514. && 1
  1515. && 1
  1516. && 1
  1517. && 1
  1518. && 1
  1519. && 1
  1520. && 1
  1521. && 1
  1522. && 1
  1523. && 1)) break;
  1524. }
  1525. foo()
  1526. {
  1527. a = cond ? foo() : asdf
  1528. + asdf;
  1529. a = cond ?
  1530. foo() : asdf
  1531. + asdf;
  1532. }
  1533. int main(void)
  1534. {
  1535. if (a)
  1536. if (b)
  1537. 2;
  1538. else 3;
  1539. next_line_of_code();
  1540. }
  1541. barry()
  1542. {
  1543. Foo::Foo (int one,
  1544. int two)
  1545. : something(4)
  1546. {}
  1547. }
  1548. barry()
  1549. {
  1550. Foo::Foo (int one, int two)
  1551. : something(4)
  1552. {}
  1553. }
  1554. Constructor::Constructor(int a,
  1555. int b
  1556. ) :
  1557. BaseClass(a,
  1558. b,
  1559. c),
  1560. mMember(b)
  1561. {
  1562. }
  1563. int main ()
  1564. {
  1565. if (lala)
  1566. do
  1567. ++(*lolo);
  1568. while (lili
  1569. && lele);
  1570. lulu;
  1571. }
  1572. int main ()
  1573. {
  1574. switch (c)
  1575. {
  1576. case 'c': if (cond)
  1577. {
  1578. }
  1579. }
  1580. }
  1581. main()
  1582. {
  1583. (void) MyFancyFuasdfadsfnction(
  1584. argument);
  1585. }
  1586. main()
  1587. {
  1588. char foo[] = "/*";
  1589. /* as
  1590. df */
  1591. hello
  1592. }
  1593. /* valid namespaces with normal indent */
  1594. namespace
  1595. {
  1596. {
  1597. 111111111111;
  1598. }
  1599. }
  1600. namespace /* test */
  1601. {
  1602. 11111111111111111;
  1603. }
  1604. namespace // test
  1605. {
  1606. 111111111111111111;
  1607. }
  1608. namespace
  1609. {
  1610. 111111111111111111;
  1611. }
  1612. namespace test
  1613. {
  1614. 111111111111111111;
  1615. }
  1616. namespace{
  1617. 111111111111111111;
  1618. }
  1619. namespace test{
  1620. 111111111111111111;
  1621. }
  1622. namespace {
  1623. 111111111111111111;
  1624. }
  1625. namespace test {
  1626. 111111111111111111;
  1627. namespace test2 {
  1628. 22222222222222222;
  1629. }
  1630. }
  1631. /* invalid namespaces use block indent */
  1632. namespace test test2 {
  1633. 111111111111111111111;
  1634. }
  1635. namespace11111111111 {
  1636. 111111111111;
  1637. }
  1638. namespace() {
  1639. 1111111111111;
  1640. }
  1641. namespace()
  1642. {
  1643. 111111111111111111;
  1644. }
  1645. namespace test test2
  1646. {
  1647. 1111111111111111111;
  1648. }
  1649. namespace111111111
  1650. {
  1651. 111111111111111111;
  1652. }
  1653. void getstring() {
  1654. /* Raw strings */
  1655. const char* s = R"(
  1656. test {
  1657. # comment
  1658. field: 123
  1659. }
  1660. )";
  1661. }
  1662. void getstring() {
  1663. const char* s = R"foo(
  1664. test {
  1665. # comment
  1666. field: 123
  1667. }
  1668. )foo";
  1669. }
  1670. {
  1671. int a[4] = {
  1672. [0] = 0,
  1673. [1] = 1,
  1674. [2] = 2,
  1675. [3] = 3,
  1676. };
  1677. }
  1678. {
  1679. a = b[2]
  1680. + 3;
  1681. }
  1682. {
  1683. if (1)
  1684. /* aaaaa
  1685. * bbbbb
  1686. */
  1687. a = 1;
  1688. }
  1689. void func()
  1690. {
  1691. switch (foo)
  1692. {
  1693. case (bar):
  1694. if (baz())
  1695. quux();
  1696. break;
  1697. case (shmoo):
  1698. if (!bar)
  1699. {
  1700. }
  1701. case (foo1):
  1702. switch (bar)
  1703. {
  1704. case baz:
  1705. baz_f();
  1706. break;
  1707. }
  1708. break;
  1709. default:
  1710. baz();
  1711. baz();
  1712. break;
  1713. }
  1714. }
  1715. /* end of AUTO */
  1716. ]=])
  1717. end)
  1718. it('2 is working', function()
  1719. insert_([=[
  1720. {
  1721. /* this is
  1722. * a real serious important big
  1723. * comment
  1724. */
  1725. /* insert " about life, the universe, and the rest" after "serious" */
  1726. }
  1727. ]=])
  1728. feed_command('set tw=0 noai fo=croq')
  1729. feed_command('let &wm = &columns - 20')
  1730. feed_command('/serious/e')
  1731. feed('a about life, the universe, and the rest<esc>')
  1732. expect([=[
  1733. {
  1734. /* this is
  1735. * a real serious
  1736. * about life, the
  1737. * universe, and the
  1738. * rest important big
  1739. * comment
  1740. */
  1741. /* insert " about life, the universe, and the rest" after "serious" */
  1742. }
  1743. ]=])
  1744. end)
  1745. it('3 is working', function()
  1746. insert_([=[
  1747. {
  1748. /*
  1749. * Testing for comments, without 'cin' set
  1750. */
  1751. /*
  1752. * what happens here?
  1753. */
  1754. /*
  1755. the end of the comment, try inserting a line below */
  1756. /* how about
  1757. this one */
  1758. }
  1759. ]=])
  1760. feed_command('set nocin')
  1761. feed_command('/comments')
  1762. feed('joabout life<esc>/happens<cr>')
  1763. feed('jothere<esc>/below<cr>')
  1764. feed('oline<esc>/this<cr>')
  1765. feed('Ohello<esc>')
  1766. expect([=[
  1767. {
  1768. /*
  1769. * Testing for comments, without 'cin' set
  1770. */
  1771. about life
  1772. /*
  1773. * what happens here?
  1774. */
  1775. there
  1776. /*
  1777. the end of the comment, try inserting a line below */
  1778. line
  1779. /* how about
  1780. hello
  1781. this one */
  1782. }
  1783. ]=])
  1784. end)
  1785. it('4 is working', function()
  1786. insert_([=[
  1787. {
  1788. var = this + that + vec[0] * vec[0]
  1789. + vec[1] * vec[1]
  1790. + vec2[2] * vec[2];
  1791. }
  1792. ]=])
  1793. feed_command('set cin')
  1794. feed_command('/vec2')
  1795. feed('==<cr>')
  1796. expect([=[
  1797. {
  1798. var = this + that + vec[0] * vec[0]
  1799. + vec[1] * vec[1]
  1800. + vec2[2] * vec[2];
  1801. }
  1802. ]=])
  1803. end)
  1804. it('5 is working', function()
  1805. insert_([=[
  1806. {
  1807. asdf asdflkajds f;
  1808. if (tes & ting) {
  1809. asdf asdf asdf ;
  1810. asdfa sdf asdf;
  1811. }
  1812. testing1;
  1813. if (tes & ting)
  1814. {
  1815. asdf asdf asdf ;
  1816. asdfa sdf asdf;
  1817. }
  1818. testing2;
  1819. }
  1820. ]=])
  1821. feed_command('set cin')
  1822. feed_command('set cino=}4')
  1823. feed_command('/testing1')
  1824. feed('k2==/testing2<cr>')
  1825. feed('k2==<cr>')
  1826. expect([=[
  1827. {
  1828. asdf asdflkajds f;
  1829. if (tes & ting) {
  1830. asdf asdf asdf ;
  1831. asdfa sdf asdf;
  1832. }
  1833. testing1;
  1834. if (tes & ting)
  1835. {
  1836. asdf asdf asdf ;
  1837. asdfa sdf asdf;
  1838. }
  1839. testing2;
  1840. }
  1841. ]=])
  1842. end)
  1843. it('6 is working', function()
  1844. insert_([=[
  1845. main ( int first_par, /*
  1846. * Comment for
  1847. * first par
  1848. */
  1849. int second_par /*
  1850. * Comment for
  1851. * second par
  1852. */
  1853. )
  1854. {
  1855. func( first_par, /*
  1856. * Comment for
  1857. * first par
  1858. */
  1859. second_par /*
  1860. * Comment for
  1861. * second par
  1862. */
  1863. );
  1864. }
  1865. ]=])
  1866. feed_command('set cin')
  1867. feed_command('set cino=(0,)20')
  1868. feed_command('/main')
  1869. feed('=][<cr>')
  1870. expect([=[
  1871. main ( int first_par, /*
  1872. * Comment for
  1873. * first par
  1874. */
  1875. int second_par /*
  1876. * Comment for
  1877. * second par
  1878. */
  1879. )
  1880. {
  1881. func( first_par, /*
  1882. * Comment for
  1883. * first par
  1884. */
  1885. second_par /*
  1886. * Comment for
  1887. * second par
  1888. */
  1889. );
  1890. }
  1891. ]=])
  1892. end)
  1893. it('7 is working', function()
  1894. insert_([=[
  1895. main(void)
  1896. {
  1897. /* Make sure that cino=X0s is not parsed like cino=Xs. */
  1898. if (cond)
  1899. foo();
  1900. else
  1901. {
  1902. bar();
  1903. }
  1904. }
  1905. ]=])
  1906. feed_command('set cin')
  1907. feed_command('set cino=es,n0s')
  1908. feed_command('/main')
  1909. feed('=][<cr>')
  1910. expect([=[
  1911. main(void)
  1912. {
  1913. /* Make sure that cino=X0s is not parsed like cino=Xs. */
  1914. if (cond)
  1915. foo();
  1916. else
  1917. {
  1918. bar();
  1919. }
  1920. }
  1921. ]=])
  1922. end)
  1923. it('8 is working', function()
  1924. insert_([=[
  1925. {
  1926. do
  1927. {
  1928. if ()
  1929. {
  1930. if ()
  1931. asdf;
  1932. else
  1933. asdf;
  1934. }
  1935. } while ();
  1936. cmd; /* this should go under the } */
  1937. }
  1938. ]=])
  1939. feed_command('set cin')
  1940. feed_command('set cino=')
  1941. feed(']]=][<cr>')
  1942. expect([=[
  1943. {
  1944. do
  1945. {
  1946. if ()
  1947. {
  1948. if ()
  1949. asdf;
  1950. else
  1951. asdf;
  1952. }
  1953. } while ();
  1954. cmd; /* this should go under the } */
  1955. }
  1956. ]=])
  1957. end)
  1958. it('9 is working', function()
  1959. insert_([=[
  1960. void f()
  1961. {
  1962. if ( k() ) {
  1963. l();
  1964. } else { /* Start (two words) end */
  1965. m();
  1966. }
  1967. n();
  1968. }
  1969. ]=])
  1970. feed(']]=][<cr>')
  1971. expect([=[
  1972. void f()
  1973. {
  1974. if ( k() ) {
  1975. l();
  1976. } else { /* Start (two words) end */
  1977. m();
  1978. }
  1979. n();
  1980. }
  1981. ]=])
  1982. end)
  1983. it('10 is working', function()
  1984. -- This is nasty. This is the only test case where the buffer content
  1985. -- differs from the original. Why? Proper behaviour of this test depends on
  1986. -- the fact that the setup code contains an (unbalanced) opening curly
  1987. -- bracket in "set cino={s,e-s". This bracket actually affects the outcome
  1988. -- of the test: without it the curly bracket under "void f()" would not be
  1989. -- indented properly. And that's why we've had to add one explicitly.
  1990. insert_([=[
  1991. { <= THIS IS THE CURLY BRACKET EXPLAINED IN THE COMMENT.
  1992. void f()
  1993. {
  1994. if ( k() )
  1995. {
  1996. l();
  1997. } else { /* Start (two words) end */
  1998. m();
  1999. }
  2000. n(); /* should be under the if () */
  2001. }
  2002. ]=])
  2003. feed_command('set cino={s,e-s')
  2004. feed(']]=][<cr>')
  2005. expect([=[
  2006. { <= THIS IS THE CURLY BRACKET EXPLAINED IN THE COMMENT.
  2007. void f()
  2008. {
  2009. if ( k() )
  2010. {
  2011. l();
  2012. } else { /* Start (two words) end */
  2013. m();
  2014. }
  2015. n(); /* should be under the if () */
  2016. }
  2017. ]=])
  2018. end)
  2019. it('11 is working', function()
  2020. insert_([=[
  2021. void bar(void)
  2022. {
  2023. static array[2][2] =
  2024. {
  2025. { 1, 2 },
  2026. { 3, 4 },
  2027. }
  2028. while (a)
  2029. {
  2030. foo(&a);
  2031. }
  2032. {
  2033. int a;
  2034. {
  2035. a = a + 1;
  2036. }
  2037. }
  2038. b = a;
  2039. }
  2040. void func(void)
  2041. {
  2042. a = 1;
  2043. {
  2044. b = 2;
  2045. }
  2046. c = 3;
  2047. d = 4;
  2048. }
  2049. /* foo */
  2050. ]=])
  2051. feed_command('set cino={s,fs')
  2052. feed(']]=/ foo<cr>')
  2053. expect([=[
  2054. void bar(void)
  2055. {
  2056. static array[2][2] =
  2057. {
  2058. { 1, 2 },
  2059. { 3, 4 },
  2060. }
  2061. while (a)
  2062. {
  2063. foo(&a);
  2064. }
  2065. {
  2066. int a;
  2067. {
  2068. a = a + 1;
  2069. }
  2070. }
  2071. b = a;
  2072. }
  2073. void func(void)
  2074. {
  2075. a = 1;
  2076. {
  2077. b = 2;
  2078. }
  2079. c = 3;
  2080. d = 4;
  2081. }
  2082. /* foo */
  2083. ]=])
  2084. end)
  2085. it('12 is working', function()
  2086. insert_([=[
  2087. a()
  2088. {
  2089. do {
  2090. a = a +
  2091. a;
  2092. } while ( a ); /* add text under this line */
  2093. if ( a )
  2094. a;
  2095. }
  2096. ]=])
  2097. feed_command('set cino=')
  2098. feed_command('/while')
  2099. feed('ohere<esc>')
  2100. expect([=[
  2101. a()
  2102. {
  2103. do {
  2104. a = a +
  2105. a;
  2106. } while ( a ); /* add text under this line */
  2107. here
  2108. if ( a )
  2109. a;
  2110. }
  2111. ]=])
  2112. end)
  2113. it('13 is working', function()
  2114. insert_([=[
  2115. a()
  2116. {
  2117. label1:
  2118. /* hmm */
  2119. // comment
  2120. }
  2121. ]=])
  2122. feed_command('set cino= com=')
  2123. feed_command('/comment')
  2124. feed('olabel2: b();<cr>label3 /* post */:<cr>/* pre */ label4:<cr>f(/*com*/);<cr>if (/*com*/)<cr>cmd();<esc>')
  2125. expect([=[
  2126. a()
  2127. {
  2128. label1:
  2129. /* hmm */
  2130. // comment
  2131. label2: b();
  2132. label3 /* post */:
  2133. /* pre */ label4:
  2134. f(/*com*/);
  2135. if (/*com*/)
  2136. cmd();
  2137. }
  2138. ]=])
  2139. end)
  2140. it('14 is working', function()
  2141. insert_([=[
  2142. /*
  2143. * A simple comment
  2144. */
  2145. /*
  2146. ** A different comment
  2147. */
  2148. ]=])
  2149. feed_command('set comments& comments^=s:/*,m:**,ex:*/')
  2150. feed_command('/simple')
  2151. feed('=5j<cr>')
  2152. expect([=[
  2153. /*
  2154. * A simple comment
  2155. */
  2156. /*
  2157. ** A different comment
  2158. */
  2159. ]=])
  2160. end)
  2161. it('15 is working', function()
  2162. insert_([=[
  2163. void f()
  2164. {
  2165. /*********
  2166. A comment.
  2167. *********/
  2168. }
  2169. ]=])
  2170. feed_command('set cino=c0')
  2171. feed_command('set comments& comments-=s1:/* comments^=s0:/*')
  2172. feed('2kdd]]=][<cr>')
  2173. expect([=[
  2174. void f()
  2175. {
  2176. /*********
  2177. A comment.
  2178. *********/
  2179. }
  2180. ]=])
  2181. end)
  2182. it('16 is working', function()
  2183. insert_([=[
  2184. void f()
  2185. {
  2186. /*********
  2187. A comment.
  2188. *********/
  2189. }
  2190. ]=])
  2191. feed_command('set cino=c0,C1')
  2192. feed_command('set comments& comments-=s1:/* comments^=s0:/*')
  2193. feed('2kdd]]=][<cr>')
  2194. expect([=[
  2195. void f()
  2196. {
  2197. /*********
  2198. A comment.
  2199. *********/
  2200. }
  2201. ]=])
  2202. end)
  2203. it('17 is working', function()
  2204. insert_([=[
  2205. void f()
  2206. {
  2207. c = c1 &&
  2208. (
  2209. c2 ||
  2210. c3
  2211. ) && c4;
  2212. }
  2213. ]=])
  2214. feed_command('set cino=')
  2215. feed(']]=][<cr>')
  2216. expect([=[
  2217. void f()
  2218. {
  2219. c = c1 &&
  2220. (
  2221. c2 ||
  2222. c3
  2223. ) && c4;
  2224. }
  2225. ]=])
  2226. end)
  2227. it('18 is working', function()
  2228. insert_([=[
  2229. void f()
  2230. {
  2231. c = c1 &&
  2232. (
  2233. c2 ||
  2234. c3
  2235. ) && c4;
  2236. }
  2237. ]=])
  2238. feed_command('set cino=(s')
  2239. feed('2kdd]]=][<cr>')
  2240. expect([=[
  2241. void f()
  2242. {
  2243. c = c1 &&
  2244. (
  2245. c2 ||
  2246. c3
  2247. ) && c4;
  2248. }
  2249. ]=])
  2250. end)
  2251. it('19 is working', function()
  2252. insert_([=[
  2253. void f()
  2254. {
  2255. c = c1 &&
  2256. (
  2257. c2 ||
  2258. c3
  2259. ) && c4;
  2260. }
  2261. ]=])
  2262. feed_command('set cino=(s,U1 ')
  2263. feed('2kdd]]=][<cr>')
  2264. expect([=[
  2265. void f()
  2266. {
  2267. c = c1 &&
  2268. (
  2269. c2 ||
  2270. c3
  2271. ) && c4;
  2272. }
  2273. ]=])
  2274. end)
  2275. it('20 is working', function()
  2276. insert_([=[
  2277. void f()
  2278. {
  2279. if ( c1
  2280. && ( c2
  2281. || c3))
  2282. foo;
  2283. }
  2284. ]=])
  2285. feed_command('set cino=(0')
  2286. feed('2kdd]]=][<cr>')
  2287. expect([=[
  2288. void f()
  2289. {
  2290. if ( c1
  2291. && ( c2
  2292. || c3))
  2293. foo;
  2294. }
  2295. ]=])
  2296. end)
  2297. it('21 is working', function()
  2298. insert_([=[
  2299. void f()
  2300. {
  2301. if ( c1
  2302. && ( c2
  2303. || c3))
  2304. foo;
  2305. }
  2306. ]=])
  2307. feed_command('set cino=(0,w1 ')
  2308. feed('2kdd]]=][<cr>')
  2309. expect([=[
  2310. void f()
  2311. {
  2312. if ( c1
  2313. && ( c2
  2314. || c3))
  2315. foo;
  2316. }
  2317. ]=])
  2318. end)
  2319. it('22 is working', function()
  2320. insert_([=[
  2321. void f()
  2322. {
  2323. c = c1 && (
  2324. c2 ||
  2325. c3
  2326. ) && c4;
  2327. if (
  2328. c1 && c2
  2329. )
  2330. foo;
  2331. }
  2332. ]=])
  2333. feed_command('set cino=(s')
  2334. feed('2kdd]]=][<cr>')
  2335. expect([=[
  2336. void f()
  2337. {
  2338. c = c1 && (
  2339. c2 ||
  2340. c3
  2341. ) && c4;
  2342. if (
  2343. c1 && c2
  2344. )
  2345. foo;
  2346. }
  2347. ]=])
  2348. end)
  2349. it('23 is working', function()
  2350. insert_([=[
  2351. void f()
  2352. {
  2353. c = c1 && (
  2354. c2 ||
  2355. c3
  2356. ) && c4;
  2357. if (
  2358. c1 && c2
  2359. )
  2360. foo;
  2361. }
  2362. ]=])
  2363. feed_command('set cino=(s,m1 ')
  2364. feed('2kdd]]=][<cr>')
  2365. expect([=[
  2366. void f()
  2367. {
  2368. c = c1 && (
  2369. c2 ||
  2370. c3
  2371. ) && c4;
  2372. if (
  2373. c1 && c2
  2374. )
  2375. foo;
  2376. }
  2377. ]=])
  2378. end)
  2379. it('24 is working', function()
  2380. insert_([=[
  2381. void f()
  2382. {
  2383. switch (x)
  2384. {
  2385. case 1:
  2386. a = b;
  2387. break;
  2388. default:
  2389. a = 0;
  2390. break;
  2391. }
  2392. }
  2393. ]=])
  2394. feed_command('set cino=b1')
  2395. feed('2kdd]]=][<cr>')
  2396. expect([=[
  2397. void f()
  2398. {
  2399. switch (x)
  2400. {
  2401. case 1:
  2402. a = b;
  2403. break;
  2404. default:
  2405. a = 0;
  2406. break;
  2407. }
  2408. }
  2409. ]=])
  2410. end)
  2411. it('25 is working', function()
  2412. insert_([=[
  2413. void f()
  2414. {
  2415. invokeme(
  2416. argu,
  2417. ment);
  2418. invokeme(
  2419. argu,
  2420. ment
  2421. );
  2422. invokeme(argu,
  2423. ment
  2424. );
  2425. }
  2426. ]=])
  2427. feed_command('set cino=(0,W5')
  2428. feed('2kdd]]=][<cr>')
  2429. expect([=[
  2430. void f()
  2431. {
  2432. invokeme(
  2433. argu,
  2434. ment);
  2435. invokeme(
  2436. argu,
  2437. ment
  2438. );
  2439. invokeme(argu,
  2440. ment
  2441. );
  2442. }
  2443. ]=])
  2444. end)
  2445. it('26 is working', function()
  2446. insert_([=[
  2447. void f()
  2448. {
  2449. statement;
  2450. // comment 1
  2451. // comment 2
  2452. }
  2453. ]=])
  2454. feed_command('set cino=/6')
  2455. feed('2kdd]]=][<cr>')
  2456. expect([=[
  2457. void f()
  2458. {
  2459. statement;
  2460. // comment 1
  2461. // comment 2
  2462. }
  2463. ]=])
  2464. end)
  2465. it('27 is working', function()
  2466. insert_([=[
  2467. void f()
  2468. {
  2469. statement;
  2470. // comment 1
  2471. // comment 2
  2472. }
  2473. ]=])
  2474. feed_command('set cino=')
  2475. feed('2kdd]]/comment 1/+1<cr>')
  2476. feed('==<cr>')
  2477. expect([=[
  2478. void f()
  2479. {
  2480. statement;
  2481. // comment 1
  2482. // comment 2
  2483. }
  2484. ]=])
  2485. end)
  2486. it('28 is working', function()
  2487. insert_([=[
  2488. class CAbc
  2489. {
  2490. int Test() { return FALSE; }
  2491. public: // comment
  2492. void testfall();
  2493. protected:
  2494. void testfall();
  2495. };
  2496. ]=])
  2497. feed_command('set cino=g0')
  2498. feed('2kdd]]=][<cr>')
  2499. expect([=[
  2500. class CAbc
  2501. {
  2502. int Test() { return FALSE; }
  2503. public: // comment
  2504. void testfall();
  2505. protected:
  2506. void testfall();
  2507. };
  2508. ]=])
  2509. end)
  2510. it('29 is working', function()
  2511. insert_([=[
  2512. class Foo : public Bar
  2513. {
  2514. public:
  2515. virtual void method1(void) = 0;
  2516. virtual void method2(int arg1,
  2517. int arg2,
  2518. int arg3) = 0;
  2519. };
  2520. ]=])
  2521. feed_command('set cino=(0,gs,hs')
  2522. feed('2kdd]]=][<cr>')
  2523. expect([=[
  2524. class Foo : public Bar
  2525. {
  2526. public:
  2527. virtual void method1(void) = 0;
  2528. virtual void method2(int arg1,
  2529. int arg2,
  2530. int arg3) = 0;
  2531. };
  2532. ]=])
  2533. end)
  2534. it('30 is working', function()
  2535. insert_([=[
  2536. void
  2537. foo()
  2538. {
  2539. if (a)
  2540. {
  2541. } else
  2542. asdf;
  2543. }
  2544. ]=])
  2545. feed_command('set cino=+20')
  2546. feed('2kdd]]=][<cr>')
  2547. expect([=[
  2548. void
  2549. foo()
  2550. {
  2551. if (a)
  2552. {
  2553. } else
  2554. asdf;
  2555. }
  2556. ]=])
  2557. end)
  2558. it('31 is working', function()
  2559. insert_([=[
  2560. {
  2561. averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
  2562. asdasdf,
  2563. func(asdf,
  2564. asdfadsf),
  2565. asdfasdf
  2566. );
  2567. /* those are ugly, but consequent */
  2568. func()->asd(asdasdf,
  2569. averylongfunctionname(
  2570. abc,
  2571. dec)->averylongfunctionname(
  2572. asdfadsf,
  2573. asdfasdf,
  2574. asdfasdf,
  2575. ),
  2576. func(asdfadf,
  2577. asdfasdf
  2578. ),
  2579. asdasdf
  2580. );
  2581. averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
  2582. abc,
  2583. dec)->asdfasdfasdf(
  2584. asdfadsf,
  2585. asdfasdf,
  2586. asdfasdf,
  2587. ),
  2588. func(asdfadf,
  2589. asdfasdf),
  2590. asdasdf
  2591. );
  2592. }
  2593. ]=])
  2594. feed_command('set cino=(0,W2s')
  2595. feed('2kdd]]=][<cr>')
  2596. expect([=[
  2597. {
  2598. averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
  2599. asdasdf,
  2600. func(asdf,
  2601. asdfadsf),
  2602. asdfasdf
  2603. );
  2604. /* those are ugly, but consequent */
  2605. func()->asd(asdasdf,
  2606. averylongfunctionname(
  2607. abc,
  2608. dec)->averylongfunctionname(
  2609. asdfadsf,
  2610. asdfasdf,
  2611. asdfasdf,
  2612. ),
  2613. func(asdfadf,
  2614. asdfasdf
  2615. ),
  2616. asdasdf
  2617. );
  2618. averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
  2619. abc,
  2620. dec)->asdfasdfasdf(
  2621. asdfadsf,
  2622. asdfasdf,
  2623. asdfasdf,
  2624. ),
  2625. func(asdfadf,
  2626. asdfasdf),
  2627. asdasdf
  2628. );
  2629. }
  2630. ]=])
  2631. end)
  2632. it('32 is working', function()
  2633. insert_([=[
  2634. int main ()
  2635. {
  2636. if (cond1 &&
  2637. cond2
  2638. )
  2639. foo;
  2640. }
  2641. ]=])
  2642. feed_command('set cino=M1')
  2643. feed('2kdd]]=][<cr>')
  2644. expect([=[
  2645. int main ()
  2646. {
  2647. if (cond1 &&
  2648. cond2
  2649. )
  2650. foo;
  2651. }
  2652. ]=])
  2653. end)
  2654. it('33 is working', function()
  2655. insert_([=[
  2656. void func(int a
  2657. #if defined(FOO)
  2658. , int b
  2659. , int c
  2660. #endif
  2661. )
  2662. {
  2663. }
  2664. ]=])
  2665. feed_command('set cino=(0,ts')
  2666. feed('2kdd2j=][<cr>')
  2667. expect([=[
  2668. void func(int a
  2669. #if defined(FOO)
  2670. , int b
  2671. , int c
  2672. #endif
  2673. )
  2674. {
  2675. }
  2676. ]=])
  2677. end)
  2678. it('34 is working', function()
  2679. insert_([=[
  2680. void
  2681. func(int a
  2682. #if defined(FOO)
  2683. , int b
  2684. , int c
  2685. #endif
  2686. )
  2687. {
  2688. }
  2689. ]=])
  2690. feed_command('set cino=(0')
  2691. feed('2kdd2j=][<cr>')
  2692. expect([=[
  2693. void
  2694. func(int a
  2695. #if defined(FOO)
  2696. , int b
  2697. , int c
  2698. #endif
  2699. )
  2700. {
  2701. }
  2702. ]=])
  2703. end)
  2704. it('35 is working', function()
  2705. insert_([=[
  2706. void func(void)
  2707. {
  2708. if(x==y)
  2709. if(y==z)
  2710. foo=1;
  2711. else { bar=1;
  2712. baz=2;
  2713. }
  2714. printf("Foo!\n");
  2715. }
  2716. void func1(void)
  2717. {
  2718. char* tab[] = {"foo", "bar",
  2719. "baz", "quux",
  2720. "this line used", "to be indented incorrectly"};
  2721. foo();
  2722. }
  2723. void func2(void)
  2724. {
  2725. int tab[] =
  2726. {1, 2,
  2727. 3, 4,
  2728. 5, 6};
  2729. printf("This line used to be indented incorrectly.\n");
  2730. }
  2731. int foo[]
  2732. #ifdef BAR
  2733. = { 1, 2, 3,
  2734. 4, 5, 6 }
  2735. #endif
  2736. ;
  2737. int baz;
  2738. void func3(void)
  2739. {
  2740. int tab[] = {
  2741. 1, 2,
  2742. 3, 4,
  2743. 5, 6};
  2744. printf("Don't you dare indent this line incorrectly!\n");
  2745. }
  2746. void
  2747. func4(a, b,
  2748. c)
  2749. int a;
  2750. int b;
  2751. int c;
  2752. {
  2753. }
  2754. void
  2755. func5(
  2756. int a,
  2757. int b)
  2758. {
  2759. }
  2760. void
  2761. func6(
  2762. int a)
  2763. {
  2764. }
  2765. ]=])
  2766. feed_command('set cino&')
  2767. feed('2kdd2j=7][<cr>')
  2768. expect([=[
  2769. void func(void)
  2770. {
  2771. if(x==y)
  2772. if(y==z)
  2773. foo=1;
  2774. else { bar=1;
  2775. baz=2;
  2776. }
  2777. printf("Foo!\n");
  2778. }
  2779. void func1(void)
  2780. {
  2781. char* tab[] = {"foo", "bar",
  2782. "baz", "quux",
  2783. "this line used", "to be indented incorrectly"};
  2784. foo();
  2785. }
  2786. void func2(void)
  2787. {
  2788. int tab[] =
  2789. {1, 2,
  2790. 3, 4,
  2791. 5, 6};
  2792. printf("This line used to be indented incorrectly.\n");
  2793. }
  2794. int foo[]
  2795. #ifdef BAR
  2796. = { 1, 2, 3,
  2797. 4, 5, 6 }
  2798. #endif
  2799. ;
  2800. int baz;
  2801. void func3(void)
  2802. {
  2803. int tab[] = {
  2804. 1, 2,
  2805. 3, 4,
  2806. 5, 6};
  2807. printf("Don't you dare indent this line incorrectly!\n");
  2808. }
  2809. void
  2810. func4(a, b,
  2811. c)
  2812. int a;
  2813. int b;
  2814. int c;
  2815. {
  2816. }
  2817. void
  2818. func5(
  2819. int a,
  2820. int b)
  2821. {
  2822. }
  2823. void
  2824. func6(
  2825. int a)
  2826. {
  2827. }
  2828. ]=])
  2829. end)
  2830. it('36 is working', function()
  2831. insert_([=[
  2832. void func(void)
  2833. {
  2834. int tab[] =
  2835. {
  2836. 1, 2, 3,
  2837. 4, 5, 6};
  2838. printf("Indent this line correctly!\n");
  2839. switch (foo)
  2840. {
  2841. case bar:
  2842. printf("bar");
  2843. break;
  2844. case baz: {
  2845. printf("baz");
  2846. break;
  2847. }
  2848. case quux:
  2849. printf("But don't break the indentation of this instruction\n");
  2850. break;
  2851. }
  2852. }
  2853. ]=])
  2854. feed_command('set cino&')
  2855. feed_command('set cino+=l1')
  2856. feed('2kdd2j=][<cr>')
  2857. expect([=[
  2858. void func(void)
  2859. {
  2860. int tab[] =
  2861. {
  2862. 1, 2, 3,
  2863. 4, 5, 6};
  2864. printf("Indent this line correctly!\n");
  2865. switch (foo)
  2866. {
  2867. case bar:
  2868. printf("bar");
  2869. break;
  2870. case baz: {
  2871. printf("baz");
  2872. break;
  2873. }
  2874. case quux:
  2875. printf("But don't break the indentation of this instruction\n");
  2876. break;
  2877. }
  2878. }
  2879. ]=])
  2880. end)
  2881. it('37 is working', function()
  2882. insert_([=[
  2883. void func(void)
  2884. {
  2885. cout << "a"
  2886. << "b"
  2887. << ") :"
  2888. << "c";
  2889. }
  2890. ]=])
  2891. feed_command('set cino&')
  2892. feed('2kdd2j=][<cr>')
  2893. expect([=[
  2894. void func(void)
  2895. {
  2896. cout << "a"
  2897. << "b"
  2898. << ") :"
  2899. << "c";
  2900. }
  2901. ]=])
  2902. end)
  2903. it('38 is working', function()
  2904. insert_([=[
  2905. void func(void)
  2906. {
  2907. /*
  2908. * This is a comment.
  2909. */
  2910. }
  2911. ]=])
  2912. feed_command('set com=s1:/*,m:*,ex:*/')
  2913. feed(']]3jofoo();<esc>')
  2914. expect([=[
  2915. void func(void)
  2916. {
  2917. /*
  2918. * This is a comment.
  2919. */
  2920. foo();
  2921. }
  2922. ]=])
  2923. end)
  2924. it('39 is working', function()
  2925. insert_([=[
  2926. void func(void)
  2927. {
  2928. for (int i = 0; i < 10; ++i)
  2929. if (i & 1) {
  2930. foo(1);
  2931. } else
  2932. foo(0);
  2933. baz();
  2934. }
  2935. ]=])
  2936. feed_command('set cino&')
  2937. feed('2kdd2j=][<cr>')
  2938. expect([=[
  2939. void func(void)
  2940. {
  2941. for (int i = 0; i < 10; ++i)
  2942. if (i & 1) {
  2943. foo(1);
  2944. } else
  2945. foo(0);
  2946. baz();
  2947. }
  2948. ]=])
  2949. end)
  2950. it('40 is working', function()
  2951. insert_([=[
  2952. void func(void)
  2953. {
  2954. if (condition1
  2955. && condition2)
  2956. action();
  2957. function(argument1
  2958. && argument2);
  2959. if (c1 && (c2 ||
  2960. c3))
  2961. foo;
  2962. if (c1 &&
  2963. (c2 || c3))
  2964. {
  2965. }
  2966. if ( c1
  2967. && ( c2
  2968. || c3))
  2969. foo;
  2970. func( c1
  2971. && ( c2
  2972. || c3))
  2973. foo;
  2974. }
  2975. ]=])
  2976. feed_command('set cino=k2s,(0')
  2977. feed('2kdd3j=][<cr>')
  2978. expect([=[
  2979. void func(void)
  2980. {
  2981. if (condition1
  2982. && condition2)
  2983. action();
  2984. function(argument1
  2985. && argument2);
  2986. if (c1 && (c2 ||
  2987. c3))
  2988. foo;
  2989. if (c1 &&
  2990. (c2 || c3))
  2991. {
  2992. }
  2993. if ( c1
  2994. && ( c2
  2995. || c3))
  2996. foo;
  2997. func( c1
  2998. && ( c2
  2999. || c3))
  3000. foo;
  3001. }
  3002. ]=])
  3003. end)
  3004. it('41 is working', function()
  3005. insert_([=[
  3006. void func(void)
  3007. {
  3008. if (condition1
  3009. && condition2)
  3010. action();
  3011. function(argument1
  3012. && argument2);
  3013. if (c1 && (c2 ||
  3014. c3))
  3015. foo;
  3016. if (c1 &&
  3017. (c2 || c3))
  3018. {
  3019. }
  3020. if ( c1
  3021. && ( c2
  3022. || c3))
  3023. foo;
  3024. func( c1
  3025. && ( c2
  3026. || c3))
  3027. foo;
  3028. }
  3029. ]=])
  3030. feed_command('set cino=k2s,(s')
  3031. feed('2kdd3j=][<cr>')
  3032. expect([=[
  3033. void func(void)
  3034. {
  3035. if (condition1
  3036. && condition2)
  3037. action();
  3038. function(argument1
  3039. && argument2);
  3040. if (c1 && (c2 ||
  3041. c3))
  3042. foo;
  3043. if (c1 &&
  3044. (c2 || c3))
  3045. {
  3046. }
  3047. if ( c1
  3048. && ( c2
  3049. || c3))
  3050. foo;
  3051. func( c1
  3052. && ( c2
  3053. || c3))
  3054. foo;
  3055. }
  3056. ]=])
  3057. end)
  3058. it('42 is working', function()
  3059. insert_([=[
  3060. void func(void)
  3061. {
  3062. if (condition1
  3063. && condition2)
  3064. action();
  3065. function(argument1
  3066. && argument2);
  3067. if (c1 && (c2 ||
  3068. c3))
  3069. foo;
  3070. if (c1 &&
  3071. (c2 || c3))
  3072. {
  3073. }
  3074. if (c123456789
  3075. && (c22345
  3076. || c3))
  3077. printf("foo\n");
  3078. c = c1 &&
  3079. (
  3080. c2 ||
  3081. c3
  3082. ) && c4;
  3083. }
  3084. ]=])
  3085. feed_command('set cino=k2s,(s,U1')
  3086. feed('2kdd3j=][<cr>')
  3087. expect([=[
  3088. void func(void)
  3089. {
  3090. if (condition1
  3091. && condition2)
  3092. action();
  3093. function(argument1
  3094. && argument2);
  3095. if (c1 && (c2 ||
  3096. c3))
  3097. foo;
  3098. if (c1 &&
  3099. (c2 || c3))
  3100. {
  3101. }
  3102. if (c123456789
  3103. && (c22345
  3104. || c3))
  3105. printf("foo\n");
  3106. c = c1 &&
  3107. (
  3108. c2 ||
  3109. c3
  3110. ) && c4;
  3111. }
  3112. ]=])
  3113. end)
  3114. it('43 is working', function()
  3115. insert_([=[
  3116. void func(void)
  3117. {
  3118. if (condition1
  3119. && condition2)
  3120. action();
  3121. function(argument1
  3122. && argument2);
  3123. if (c1 && (c2 ||
  3124. c3))
  3125. foo;
  3126. if (c1 &&
  3127. (c2 || c3))
  3128. {
  3129. }
  3130. if (c123456789
  3131. && (c22345
  3132. || c3))
  3133. printf("foo\n");
  3134. if ( c1
  3135. && ( c2
  3136. || c3))
  3137. foo;
  3138. a_long_line(
  3139. argument,
  3140. argument);
  3141. a_short_line(argument,
  3142. argument);
  3143. }
  3144. ]=])
  3145. feed_command('set cino=k2s,(0,W4')
  3146. feed('2kdd3j=][<cr>')
  3147. expect([=[
  3148. void func(void)
  3149. {
  3150. if (condition1
  3151. && condition2)
  3152. action();
  3153. function(argument1
  3154. && argument2);
  3155. if (c1 && (c2 ||
  3156. c3))
  3157. foo;
  3158. if (c1 &&
  3159. (c2 || c3))
  3160. {
  3161. }
  3162. if (c123456789
  3163. && (c22345
  3164. || c3))
  3165. printf("foo\n");
  3166. if ( c1
  3167. && ( c2
  3168. || c3))
  3169. foo;
  3170. a_long_line(
  3171. argument,
  3172. argument);
  3173. a_short_line(argument,
  3174. argument);
  3175. }
  3176. ]=])
  3177. end)
  3178. it('44 is working', function()
  3179. insert_([=[
  3180. void func(void)
  3181. {
  3182. if (condition1
  3183. && condition2)
  3184. action();
  3185. function(argument1
  3186. && argument2);
  3187. if (c1 && (c2 ||
  3188. c3))
  3189. foo;
  3190. if (c1 &&
  3191. (c2 || c3))
  3192. {
  3193. }
  3194. if (c123456789
  3195. && (c22345
  3196. || c3))
  3197. printf("foo\n");
  3198. }
  3199. ]=])
  3200. feed_command('set cino=k2s,u2')
  3201. feed('2kdd3j=][<cr>')
  3202. expect([=[
  3203. void func(void)
  3204. {
  3205. if (condition1
  3206. && condition2)
  3207. action();
  3208. function(argument1
  3209. && argument2);
  3210. if (c1 && (c2 ||
  3211. c3))
  3212. foo;
  3213. if (c1 &&
  3214. (c2 || c3))
  3215. {
  3216. }
  3217. if (c123456789
  3218. && (c22345
  3219. || c3))
  3220. printf("foo\n");
  3221. }
  3222. ]=])
  3223. end)
  3224. it('45 is working', function()
  3225. insert_([=[
  3226. void func(void)
  3227. {
  3228. if (condition1
  3229. && condition2)
  3230. action();
  3231. function(argument1
  3232. && argument2);
  3233. if (c1 && (c2 ||
  3234. c3))
  3235. foo;
  3236. if (c1 &&
  3237. (c2 || c3))
  3238. {
  3239. }
  3240. if (c123456789
  3241. && (c22345
  3242. || c3))
  3243. printf("foo\n");
  3244. if ( c1
  3245. && ( c2
  3246. || c3))
  3247. foo;
  3248. func( c1
  3249. && ( c2
  3250. || c3))
  3251. foo;
  3252. }
  3253. ]=])
  3254. feed_command('set cino=k2s,(0,w1')
  3255. feed('2kdd3j=][<cr>')
  3256. expect([=[
  3257. void func(void)
  3258. {
  3259. if (condition1
  3260. && condition2)
  3261. action();
  3262. function(argument1
  3263. && argument2);
  3264. if (c1 && (c2 ||
  3265. c3))
  3266. foo;
  3267. if (c1 &&
  3268. (c2 || c3))
  3269. {
  3270. }
  3271. if (c123456789
  3272. && (c22345
  3273. || c3))
  3274. printf("foo\n");
  3275. if ( c1
  3276. && ( c2
  3277. || c3))
  3278. foo;
  3279. func( c1
  3280. && ( c2
  3281. || c3))
  3282. foo;
  3283. }
  3284. ]=])
  3285. end)
  3286. it('46 is working', function()
  3287. insert_([=[
  3288. void func(void)
  3289. {
  3290. if (condition1
  3291. && condition2)
  3292. action();
  3293. function(argument1
  3294. && argument2);
  3295. if (c1 && (c2 ||
  3296. c3))
  3297. foo;
  3298. if (c1 &&
  3299. (c2 || c3))
  3300. {
  3301. }
  3302. }
  3303. ]=])
  3304. feed_command('set cino=k2,(s')
  3305. feed('2kdd3j=][<cr>')
  3306. expect([=[
  3307. void func(void)
  3308. {
  3309. if (condition1
  3310. && condition2)
  3311. action();
  3312. function(argument1
  3313. && argument2);
  3314. if (c1 && (c2 ||
  3315. c3))
  3316. foo;
  3317. if (c1 &&
  3318. (c2 || c3))
  3319. {
  3320. }
  3321. }
  3322. ]=])
  3323. end)
  3324. it('47 is working', function()
  3325. insert_([=[
  3326. NAMESPACESTART
  3327. /* valid namespaces with normal indent */
  3328. namespace
  3329. {
  3330. {
  3331. 111111111111;
  3332. }
  3333. }
  3334. namespace /* test */
  3335. {
  3336. 11111111111111111;
  3337. }
  3338. namespace // test
  3339. {
  3340. 111111111111111111;
  3341. }
  3342. namespace
  3343. {
  3344. 111111111111111111;
  3345. }
  3346. namespace test
  3347. {
  3348. 111111111111111111;
  3349. }
  3350. namespace test::cpp17
  3351. {
  3352. 111111111111111111;
  3353. }
  3354. namespace ::incorrectcpp17
  3355. {
  3356. 111111111111111111;
  3357. }
  3358. namespace test::incorrectcpp17::
  3359. {
  3360. 111111111111111111;
  3361. }
  3362. namespace test:incorrectcpp17
  3363. {
  3364. 111111111111111111;
  3365. }
  3366. namespace test:::incorrectcpp17
  3367. {
  3368. 111111111111111111;
  3369. }
  3370. namespace{
  3371. 111111111111111111;
  3372. }
  3373. namespace test{
  3374. 111111111111111111;
  3375. }
  3376. namespace {
  3377. 111111111111111111;
  3378. }
  3379. namespace test {
  3380. 111111111111111111;
  3381. namespace test2 {
  3382. 22222222222222222;
  3383. }
  3384. }
  3385. /* invalid namespaces use block indent */
  3386. namespace test test2 {
  3387. 111111111111111111111;
  3388. }
  3389. namespace11111111111 {
  3390. 111111111111;
  3391. }
  3392. namespace() {
  3393. 1111111111111;
  3394. }
  3395. namespace()
  3396. {
  3397. 111111111111111111;
  3398. }
  3399. namespace test test2
  3400. {
  3401. 1111111111111111111;
  3402. }
  3403. namespace111111111
  3404. {
  3405. 111111111111111111;
  3406. }
  3407. NAMESPACEEND
  3408. ]=])
  3409. feed_command('set cino=N-s')
  3410. feed_command('/^NAMESPACESTART')
  3411. feed('=/^NAMESPACEEND<cr>')
  3412. expect([=[
  3413. NAMESPACESTART
  3414. /* valid namespaces with normal indent */
  3415. namespace
  3416. {
  3417. {
  3418. 111111111111;
  3419. }
  3420. }
  3421. namespace /* test */
  3422. {
  3423. 11111111111111111;
  3424. }
  3425. namespace // test
  3426. {
  3427. 111111111111111111;
  3428. }
  3429. namespace
  3430. {
  3431. 111111111111111111;
  3432. }
  3433. namespace test
  3434. {
  3435. 111111111111111111;
  3436. }
  3437. namespace test::cpp17
  3438. {
  3439. 111111111111111111;
  3440. }
  3441. namespace ::incorrectcpp17
  3442. {
  3443. 111111111111111111;
  3444. }
  3445. namespace test::incorrectcpp17::
  3446. {
  3447. 111111111111111111;
  3448. }
  3449. namespace test:incorrectcpp17
  3450. {
  3451. 111111111111111111;
  3452. }
  3453. namespace test:::incorrectcpp17
  3454. {
  3455. 111111111111111111;
  3456. }
  3457. namespace{
  3458. 111111111111111111;
  3459. }
  3460. namespace test{
  3461. 111111111111111111;
  3462. }
  3463. namespace {
  3464. 111111111111111111;
  3465. }
  3466. namespace test {
  3467. 111111111111111111;
  3468. namespace test2 {
  3469. 22222222222222222;
  3470. }
  3471. }
  3472. /* invalid namespaces use block indent */
  3473. namespace test test2 {
  3474. 111111111111111111111;
  3475. }
  3476. namespace11111111111 {
  3477. 111111111111;
  3478. }
  3479. namespace() {
  3480. 1111111111111;
  3481. }
  3482. namespace()
  3483. {
  3484. 111111111111111111;
  3485. }
  3486. namespace test test2
  3487. {
  3488. 1111111111111111111;
  3489. }
  3490. namespace111111111
  3491. {
  3492. 111111111111111111;
  3493. }
  3494. NAMESPACEEND
  3495. ]=])
  3496. end)
  3497. it('48 is working', function()
  3498. insert_([=[
  3499. JSSTART
  3500. var bar = {
  3501. foo: {
  3502. that: this,
  3503. some: ok,
  3504. },
  3505. "bar":{
  3506. a : 2,
  3507. b: "123abc",
  3508. x: 4,
  3509. "y": 5
  3510. }
  3511. }
  3512. JSEND
  3513. ]=])
  3514. feed_command('set cino=j1,J1')
  3515. feed_command('/^JSSTART')
  3516. feed('=/^JSEND<cr>')
  3517. expect([=[
  3518. JSSTART
  3519. var bar = {
  3520. foo: {
  3521. that: this,
  3522. some: ok,
  3523. },
  3524. "bar":{
  3525. a : 2,
  3526. b: "123abc",
  3527. x: 4,
  3528. "y": 5
  3529. }
  3530. }
  3531. JSEND
  3532. ]=])
  3533. end)
  3534. it('49 is working', function()
  3535. insert_([=[
  3536. JSSTART
  3537. var foo = [
  3538. 1,
  3539. 2,
  3540. 3
  3541. ];
  3542. JSEND
  3543. ]=])
  3544. feed_command('set cino=j1,J1')
  3545. feed_command('/^JSSTART')
  3546. feed('=/^JSEND<cr>')
  3547. expect([=[
  3548. JSSTART
  3549. var foo = [
  3550. 1,
  3551. 2,
  3552. 3
  3553. ];
  3554. JSEND
  3555. ]=])
  3556. end)
  3557. it('50 is working', function()
  3558. insert_([=[
  3559. JSSTART
  3560. function bar() {
  3561. var foo = [
  3562. 1,
  3563. 2,
  3564. 3
  3565. ];
  3566. }
  3567. JSEND
  3568. ]=])
  3569. feed_command('set cino=j1,J1')
  3570. feed_command('/^JSSTART')
  3571. feed('=/^JSEND<cr>')
  3572. expect([=[
  3573. JSSTART
  3574. function bar() {
  3575. var foo = [
  3576. 1,
  3577. 2,
  3578. 3
  3579. ];
  3580. }
  3581. JSEND
  3582. ]=])
  3583. end)
  3584. it('51 is working', function()
  3585. insert_([=[
  3586. JSSTART
  3587. (function($){
  3588. if (cond &&
  3589. cond) {
  3590. stmt;
  3591. }
  3592. window.something.left =
  3593. (width - 50 + offset) + "px";
  3594. var class_name='myclass';
  3595. function private_method() {
  3596. }
  3597. var public_method={
  3598. method: function(options,args){
  3599. private_method();
  3600. }
  3601. }
  3602. function init(options) {
  3603. $(this).data(class_name+'_public',$.extend({},{
  3604. foo: 'bar',
  3605. bar: 2,
  3606. foobar: [
  3607. 1,
  3608. 2,
  3609. 3
  3610. ],
  3611. callback: function(){
  3612. return true;
  3613. }
  3614. }, options||{}));
  3615. }
  3616. $.fn[class_name]=function() {
  3617. var _arguments=arguments;
  3618. return this.each(function(){
  3619. var options=$(this).data(class_name+'_public');
  3620. if (!options) {
  3621. init.apply(this,_arguments);
  3622. } else {
  3623. var method=public_method[_arguments[0]];
  3624. if (typeof(method)!='function') {
  3625. console.log(class_name+' has no method "'+_arguments[0]+'"');
  3626. return false;
  3627. }
  3628. _arguments[0]=options;
  3629. method.apply(this,_arguments);
  3630. }
  3631. });
  3632. }
  3633. })(jQuery);
  3634. JSEND
  3635. ]=])
  3636. feed_command('set cino=j1,J1')
  3637. feed_command('/^JSSTART')
  3638. feed('=/^JSEND<cr>')
  3639. expect([=[
  3640. JSSTART
  3641. (function($){
  3642. if (cond &&
  3643. cond) {
  3644. stmt;
  3645. }
  3646. window.something.left =
  3647. (width - 50 + offset) + "px";
  3648. var class_name='myclass';
  3649. function private_method() {
  3650. }
  3651. var public_method={
  3652. method: function(options,args){
  3653. private_method();
  3654. }
  3655. }
  3656. function init(options) {
  3657. $(this).data(class_name+'_public',$.extend({},{
  3658. foo: 'bar',
  3659. bar: 2,
  3660. foobar: [
  3661. 1,
  3662. 2,
  3663. 3
  3664. ],
  3665. callback: function(){
  3666. return true;
  3667. }
  3668. }, options||{}));
  3669. }
  3670. $.fn[class_name]=function() {
  3671. var _arguments=arguments;
  3672. return this.each(function(){
  3673. var options=$(this).data(class_name+'_public');
  3674. if (!options) {
  3675. init.apply(this,_arguments);
  3676. } else {
  3677. var method=public_method[_arguments[0]];
  3678. if (typeof(method)!='function') {
  3679. console.log(class_name+' has no method "'+_arguments[0]+'"');
  3680. return false;
  3681. }
  3682. _arguments[0]=options;
  3683. method.apply(this,_arguments);
  3684. }
  3685. });
  3686. }
  3687. })(jQuery);
  3688. JSEND
  3689. ]=])
  3690. end)
  3691. it('52 is working', function()
  3692. insert_([=[
  3693. JSSTART
  3694. function init(options) {
  3695. $(this).data(class_name+'_public',$.extend({},{
  3696. foo: 'bar',
  3697. bar: 2,
  3698. foobar: [
  3699. 1,
  3700. 2,
  3701. 3
  3702. ],
  3703. callback: function(){
  3704. return true;
  3705. }
  3706. }, options||{}));
  3707. }
  3708. JSEND
  3709. ]=])
  3710. feed_command('set cino=j1,J1')
  3711. feed_command('/^JSSTART')
  3712. feed('=/^JSEND<cr>')
  3713. expect([=[
  3714. JSSTART
  3715. function init(options) {
  3716. $(this).data(class_name+'_public',$.extend({},{
  3717. foo: 'bar',
  3718. bar: 2,
  3719. foobar: [
  3720. 1,
  3721. 2,
  3722. 3
  3723. ],
  3724. callback: function(){
  3725. return true;
  3726. }
  3727. }, options||{}));
  3728. }
  3729. JSEND
  3730. ]=])
  3731. end)
  3732. it('53 is working', function()
  3733. insert_([=[
  3734. JSSTART
  3735. (function($){
  3736. function init(options) {
  3737. $(this).data(class_name+'_public',$.extend({},{
  3738. foo: 'bar',
  3739. bar: 2,
  3740. foobar: [
  3741. 1,
  3742. 2,
  3743. 3
  3744. ],
  3745. callback: function(){
  3746. return true;
  3747. }
  3748. }, options||{}));
  3749. }
  3750. })(jQuery);
  3751. JSEND
  3752. ]=])
  3753. feed_command('set cino=j1,J1')
  3754. feed_command('/^JSSTART')
  3755. feed('=/^JSEND<cr>')
  3756. expect([=[
  3757. JSSTART
  3758. (function($){
  3759. function init(options) {
  3760. $(this).data(class_name+'_public',$.extend({},{
  3761. foo: 'bar',
  3762. bar: 2,
  3763. foobar: [
  3764. 1,
  3765. 2,
  3766. 3
  3767. ],
  3768. callback: function(){
  3769. return true;
  3770. }
  3771. }, options||{}));
  3772. }
  3773. })(jQuery);
  3774. JSEND
  3775. ]=])
  3776. end)
  3777. it('javascript indent / vim-patch 7.4.670', function()
  3778. insert_([=[
  3779. JSSTART
  3780. // Results of JavaScript indent
  3781. // 1
  3782. (function(){
  3783. var a = [
  3784. 'a',
  3785. 'b',
  3786. 'c',
  3787. 'd',
  3788. 'e',
  3789. 'f',
  3790. 'g',
  3791. 'h',
  3792. 'i'
  3793. ];
  3794. }())
  3795. // 2
  3796. (function(){
  3797. var a = [
  3798. 0 +
  3799. 5 *
  3800. 9 *
  3801. 'a',
  3802. 'b',
  3803. 0 +
  3804. 5 *
  3805. 9 *
  3806. 'c',
  3807. 'd',
  3808. 'e',
  3809. 'f',
  3810. 'g',
  3811. 'h',
  3812. 'i'
  3813. ];
  3814. }())
  3815. // 3
  3816. (function(){
  3817. var a = [
  3818. 0 +
  3819. // comment 1
  3820. 5 *
  3821. /* comment 2 */
  3822. 9 *
  3823. 'a',
  3824. 'b',
  3825. 0 +
  3826. 5 *
  3827. 9 *
  3828. 'c',
  3829. 'd',
  3830. 'e',
  3831. 'f',
  3832. 'g',
  3833. 'h',
  3834. 'i'
  3835. ];
  3836. }())
  3837. // 4
  3838. {
  3839. var a = [
  3840. 0,
  3841. 1
  3842. ];
  3843. var b;
  3844. var c;
  3845. }
  3846. // 5
  3847. {
  3848. var a = [
  3849. [
  3850. 0
  3851. ],
  3852. 2,
  3853. 3
  3854. ];
  3855. }
  3856. // 6
  3857. {
  3858. var a = [
  3859. [
  3860. 0,
  3861. 1
  3862. ],
  3863. 2,
  3864. 3
  3865. ];
  3866. }
  3867. // 7
  3868. {
  3869. var a = [
  3870. // [
  3871. 0,
  3872. // 1
  3873. // ],
  3874. 2,
  3875. 3
  3876. ];
  3877. }
  3878. // 8
  3879. var x = [
  3880. (function(){
  3881. var a,
  3882. b,
  3883. c,
  3884. d,
  3885. e,
  3886. f,
  3887. g,
  3888. h,
  3889. i;
  3890. })
  3891. ];
  3892. // 9
  3893. var a = [
  3894. 0 +
  3895. 5 *
  3896. 9 *
  3897. 'a',
  3898. 'b',
  3899. 0 +
  3900. 5 *
  3901. 9 *
  3902. 'c',
  3903. 'd',
  3904. 'e',
  3905. 'f',
  3906. 'g',
  3907. 'h',
  3908. 'i'
  3909. ];
  3910. // 10
  3911. var a,
  3912. b,
  3913. c,
  3914. d,
  3915. e,
  3916. f,
  3917. g,
  3918. h,
  3919. i;
  3920. JSEND
  3921. ]=])
  3922. -- :set cino=j1,J1,+2
  3923. feed_command('set cino=j1,J1,+2')
  3924. feed_command('/^JSSTART')
  3925. feed('=/^JSEND<cr>')
  3926. expect([=[
  3927. JSSTART
  3928. // Results of JavaScript indent
  3929. // 1
  3930. (function(){
  3931. var a = [
  3932. 'a',
  3933. 'b',
  3934. 'c',
  3935. 'd',
  3936. 'e',
  3937. 'f',
  3938. 'g',
  3939. 'h',
  3940. 'i'
  3941. ];
  3942. }())
  3943. // 2
  3944. (function(){
  3945. var a = [
  3946. 0 +
  3947. 5 *
  3948. 9 *
  3949. 'a',
  3950. 'b',
  3951. 0 +
  3952. 5 *
  3953. 9 *
  3954. 'c',
  3955. 'd',
  3956. 'e',
  3957. 'f',
  3958. 'g',
  3959. 'h',
  3960. 'i'
  3961. ];
  3962. }())
  3963. // 3
  3964. (function(){
  3965. var a = [
  3966. 0 +
  3967. // comment 1
  3968. 5 *
  3969. /* comment 2 */
  3970. 9 *
  3971. 'a',
  3972. 'b',
  3973. 0 +
  3974. 5 *
  3975. 9 *
  3976. 'c',
  3977. 'd',
  3978. 'e',
  3979. 'f',
  3980. 'g',
  3981. 'h',
  3982. 'i'
  3983. ];
  3984. }())
  3985. // 4
  3986. {
  3987. var a = [
  3988. 0,
  3989. 1
  3990. ];
  3991. var b;
  3992. var c;
  3993. }
  3994. // 5
  3995. {
  3996. var a = [
  3997. [
  3998. 0
  3999. ],
  4000. 2,
  4001. 3
  4002. ];
  4003. }
  4004. // 6
  4005. {
  4006. var a = [
  4007. [
  4008. 0,
  4009. 1
  4010. ],
  4011. 2,
  4012. 3
  4013. ];
  4014. }
  4015. // 7
  4016. {
  4017. var a = [
  4018. // [
  4019. 0,
  4020. // 1
  4021. // ],
  4022. 2,
  4023. 3
  4024. ];
  4025. }
  4026. // 8
  4027. var x = [
  4028. (function(){
  4029. var a,
  4030. b,
  4031. c,
  4032. d,
  4033. e,
  4034. f,
  4035. g,
  4036. h,
  4037. i;
  4038. })
  4039. ];
  4040. // 9
  4041. var a = [
  4042. 0 +
  4043. 5 *
  4044. 9 *
  4045. 'a',
  4046. 'b',
  4047. 0 +
  4048. 5 *
  4049. 9 *
  4050. 'c',
  4051. 'd',
  4052. 'e',
  4053. 'f',
  4054. 'g',
  4055. 'h',
  4056. 'i'
  4057. ];
  4058. // 10
  4059. var a,
  4060. b,
  4061. c,
  4062. d,
  4063. e,
  4064. f,
  4065. g,
  4066. h,
  4067. i;
  4068. JSEND
  4069. ]=])
  4070. end)
  4071. it('line continuations in macros / vim-patch 8.0.0148', function()
  4072. insert_([=[
  4073. /* start of define */
  4074. {
  4075. }
  4076. #define AAA \
  4077. BBB\
  4078. CCC
  4079. #define CNT \
  4080. 1 + \
  4081. 2 + \
  4082. 4
  4083. /* end of define */]=])
  4084. feed_command('set cino&')
  4085. feed_command('/start of define')
  4086. feed('=/end of define<cr>')
  4087. expect([=[
  4088. /* start of define */
  4089. {
  4090. }
  4091. #define AAA \
  4092. BBB\
  4093. CCC
  4094. #define CNT \
  4095. 1 + \
  4096. 2 + \
  4097. 4
  4098. /* end of define */]=])
  4099. end)
  4100. it('* immediately follows comment / vim-patch 8.0.1291', function()
  4101. insert_([=[
  4102. {
  4103. a = second/*bug*/*line;
  4104. }]=])
  4105. feed_command('set cin cino&')
  4106. feed_command('/a = second')
  4107. feed('ox')
  4108. expect([=[
  4109. {
  4110. a = second/*bug*/*line;
  4111. x
  4112. }]=])
  4113. end)
  4114. end)