├── tests ├── dll │ ├── nimhcr_1.nim │ ├── nimhcr_2.nim │ ├── nimhcr_1_3.nim │ ├── nimhcr_2_3.nim │ ├── client.nim.cfg │ ├── server.nim.cfg │ ├── nimhcr_unit.nim.cfg │ ├── nimhcr_0_5.nim │ ├── nimhcr_1_2.nim │ ├── nimhcr_0.nim │ ├── nimhcr_0_6.nim │ └── nimhcr_2_2.nim ├── newconfig │ ├── bar │ │ ├── mfoo.nim │ │ ├── nim.cfg │ │ ├── config.nims │ │ ├── mfoo.nim.cfg │ │ └── mfoo.nims │ ├── foo2 │ │ └── mfoo2.customext │ ├── mymath.nim │ └── mconfigcheck.nims ├── import_in_config │ ├── other.nim │ ├── tmain.nim │ └── nim.cfg ├── misc │ ├── m20456.nims │ ├── m15316.nim │ ├── m20149.nim │ ├── modulea.nim │ ├── tmodulea.nim │ ├── 99bottles.nim │ ├── temptyecho.nim │ ├── thints_off.nim │ ├── tparedef.nim │ ├── t12480.nim │ ├── minit.nim │ ├── t9710.nim │ ├── mvarious.nim │ ├── m15955.nim │ ├── mbetterrun.nim │ ├── tnewderef.nim │ ├── tsamename2.nim │ ├── tinc.nim │ ├── tnewsets.nim │ ├── tcharinc.nim │ ├── mspellsuggest.nim │ ├── tgcregions.nim │ ├── tnolen.nim │ ├── tjoinable.nim │ ├── tfib.nim │ ├── mjsondoc.nim │ ├── åäö.nim │ ├── tnoop.nim │ ├── trawstr.nim │ ├── tsimtych.nim │ ├── tnoforward.nim │ ├── tdangerisrelease.nim │ ├── tinvalidarrayaccess2.nim │ ├── tissue710.nim │ ├── tinit.nim │ └── tinout.nim ├── arc │ ├── testfile.txt │ ├── nim.cfg │ ├── bmodule.nim │ ├── t14864.nim │ ├── cmodule.nim │ ├── t16458.nim │ ├── t20456.nim │ ├── tamodule.nim │ ├── t18971.nim │ ├── t17173.nim │ ├── t16033.nim │ ├── t16558.nim │ └── timportedobj.nim ├── async │ ├── hello.txt │ ├── nim.cfg │ ├── tioselectors.nim.cfg │ ├── ttemplateinasync.nim │ ├── tasync_nofuture.nim │ ├── t7192.nim │ ├── tnestedpfuturetypeparam.nim │ ├── tgenericasync.nim │ ├── tdiscardableproc.nim │ ├── tmultisync.nim │ └── t15148.nim ├── compiles │ ├── mstaticlib.nim │ └── t8630.nim ├── package │ ├── stdlib │ │ ├── stdlib.nimble │ │ └── system.nim │ └── tstdlib_name_not_special.nim ├── stdlib │ ├── tdb.nims │ ├── ttypeinfo.nims │ ├── tbitops.nim.cfg │ ├── t9754.nim │ ├── tjsontestsuite.nim │ ├── config.nims │ ├── nre │ │ ├── optional_nonstrict.nim │ │ └── escape.nim │ ├── osproctest.nim │ ├── toserrors.nim │ ├── tterminal.nim │ ├── tintsets.nim │ ├── tterminal_15874.nim │ ├── t15663.nim │ ├── tstrtabs.nims │ ├── t7686.nim │ ├── tfenv.nim │ ├── tmemlines.nim │ ├── mjsonexternproc.nim │ ├── tjsonexternproc.nim │ ├── tlocks.nim │ ├── tssl.nims │ ├── tterminal_12759.nim │ ├── concurrency │ │ └── atomicSample.nim │ ├── t14139.nim │ ├── mintsets.nim │ ├── tos_unc.nim │ ├── tcmdline.nim │ ├── tmemfiles1.nim │ └── tparseuints.nim ├── threads │ ├── nim.cfg │ └── tjsthreads.nim ├── vm │ ├── tgorge.bat │ ├── tgorge.sh │ ├── tgorgeex.bat │ ├── tgorgeex.sh │ ├── tconst_float_as_int.nim │ ├── tcgemptycallarg.nim │ ├── tnilref.nim │ ├── t19199.nim │ ├── t17039.nim │ ├── tclosureiterator.nim │ ├── toverflowopcsubimmint.nim │ ├── twrongconst.nim │ ├── toverflowopcaddimmint.nim │ ├── toverflowopcmulint.nim │ ├── tvarsection.nim │ ├── toverflowopcaddint.nim │ ├── toverflowopcsubint.nim │ ├── twrongwhen.nim │ ├── textensionmap.nim │ ├── t2574.nim │ └── tconstprocassignments.nim ├── dummy.txt ├── gc │ ├── gctest.nim.cfg │ └── tstandalone.nim ├── manyloc │ ├── packages │ │ ├── package1 │ │ │ ├── p1.babel │ │ │ └── strutils.nim │ │ ├── package2 │ │ │ ├── p2.babel │ │ │ └── strutils.nim │ │ ├── noconflicts.nim.cfg │ │ └── os.nim │ ├── nake │ │ └── nakefile.nim.cfg │ ├── standalone │ │ └── barebone.nim.cfg │ ├── keineschweine │ │ ├── dependencies │ │ │ └── sfml │ │ │ │ └── sfml_vector.nim │ │ ├── server │ │ │ ├── nim.cfg │ │ │ └── dirserver_settings.json │ │ └── enet_server │ │ │ ├── server_settings.json │ │ │ └── nim.cfg │ ├── argument_parser │ │ └── ex_wget.nim.cfg │ ├── standalone2 │ │ ├── tavr.nim.cfg │ │ └── tavr.nim │ └── named_argument_bug │ │ ├── main.nim.cfg │ │ └── tri_engine │ │ ├── config.nim │ │ └── math │ │ ├── circle.nim │ │ └── rect.nim ├── method │ ├── nim.cfg │ ├── tmethod.nim │ └── mmultim3.nim ├── modules │ ├── m9627 │ │ ├── a.nim │ │ └── b.nim │ ├── mrecmod.nim │ ├── mnamspc1.nim │ ├── mnotuniquename.nim │ ├── morder_depb.nim │ ├── a │ │ ├── utils.nim │ │ └── module_name_clashes.nim │ ├── b │ │ ├── utils.nim │ │ └── module_name_clashes.nim │ ├── mimport_in_config.nim │ ├── mnamspc2.nim │ ├── proxy_module.nim │ ├── tnotuniquename_dir │ │ └── mnotuniquename.nim │ ├── seq.nim │ ├── t8665.nim │ ├── timport_in_config.nim.cfg │ ├── mexport2b.nim │ ├── mforwarded_pure_enum2.nim │ ├── mrange.nim │ ├── morder_depa.nim │ ├── tutils_ab.nim │ ├── UpperCased.nim │ ├── mmodule_same_proc_client.nim │ ├── mforwarded_pure_enum.nim │ ├── t9627.nim │ ├── tseq.nim │ ├── definitions.nim │ ├── tfowarded_pure_enum.nim │ ├── tincludeas.nim │ ├── mexport2a.nim │ ├── mexportb.nim │ ├── tuppercased.nim │ ├── mopaque.nim │ ├── torder_dep.nim │ ├── mexporta.nim │ ├── texplicit_system_import.nim │ ├── timport_in_config.nim │ ├── tmodule_same_proc.nim │ ├── timportexcept.nim │ ├── trecmod.nim │ ├── tnotuniquename.nim │ ├── mmodule_same_proc.nim │ ├── trecinca.nim │ ├── trecincb.nim │ ├── mrecmod2.nim │ ├── texport2.nim │ ├── tnamspc.nim │ ├── tnotuniquename2.nim │ ├── tselfimport.nim │ ├── tambig_range.nim │ ├── texport.nim │ └── tmismatchedvisibility.nim ├── compilerapi │ ├── invalid.nim │ └── exposed.nim ├── destructor │ ├── nim.cfg │ ├── helper.nim │ ├── tconst_smart_ptr.nim │ ├── objFile.nim │ ├── tglobaldestructor.nim │ ├── tgotoexceptions3.nim │ └── tsetjmp_raise.nim ├── nimdoc │ ├── imp.nim │ ├── sub │ │ ├── imp.nim │ │ ├── imp2.nim │ │ └── mmain.nim │ ├── readme.md │ └── t17615.nim ├── package_level_objects │ ├── mypackage.nimble │ └── definefoo.nim ├── pragmas │ ├── mused2c.nim │ ├── mused2b.nim │ ├── cfunction.c │ ├── foobar.nim │ ├── tuserpragma.nim │ ├── warn_module.nim │ ├── t4384.nim │ ├── tpushexperimental.nim │ ├── tsym_as_pragma.nim │ ├── t13306.nim │ ├── tcompile_pragma.nim │ ├── custom_pragma.nim │ ├── t12558.nim │ ├── t5149.nim │ ├── tpush.nim │ └── mused3b.nim ├── tools │ ├── config.nims │ ├── compile │ │ ├── config.nims │ │ ├── readme.md │ │ ├── tkoch.nim │ │ ├── tdeps.nim │ │ ├── tniminst.nim │ │ └── tdetect.nim │ ├── second.nim │ └── dontmentionme.nim ├── assert │ ├── config.nims │ ├── tunittests.nim │ └── tuserassert.nim ├── compiler │ ├── tcmdlinecpuamd64.nim.cfg │ ├── tcmdlineoswin.nim.cfg │ ├── tcmdlineclib.nim │ ├── samplelib.nim │ ├── tgrammar.nim │ └── t12684.nim ├── constr │ ├── a.nim │ ├── b.nim │ ├── tglobal.nim │ ├── t18990.nim │ ├── a_module.nim │ └── tnocompiletimefunclambda.nim ├── coroutines │ ├── tgc.nim.cfg │ ├── twait.nim.cfg │ ├── texceptions.nim.cfg │ └── titerators.nim.cfg ├── niminaction │ ├── Chapter3 │ │ ├── various3.nim.cfg │ │ └── ChatApp │ │ │ └── src │ │ │ └── client.nim.cfg │ ├── Chapter6 │ │ └── WikipediaStats │ │ │ ├── concurrency.nim.cfg │ │ │ ├── parallel_counts.nim.cfg │ │ │ ├── race_condition.nim.cfg │ │ │ ├── unguarded_access.nim.cfg │ │ │ └── concurrency_regex.nim.cfg │ ├── Chapter7 │ │ └── Tweeter │ │ │ ├── tests │ │ │ └── database_test.nims │ │ │ └── src │ │ │ └── createDatabase.nim │ └── Chapter2 │ │ ├── no_iterator.nim │ │ ├── no_seq_type.nim │ │ └── explicit_discard.nim ├── js │ ├── tdiscard.nim │ ├── t8231.nim │ ├── tfloatround.nim │ ├── t7127.nim │ ├── t11697.nim │ ├── tcsymbol.nim │ ├── testtojsstr.nim │ ├── t20233.nim │ ├── temptyseq.nim │ ├── t7534.nim │ ├── tmodify_cstring.nim │ ├── t14570.nim │ ├── t8821.nim │ ├── t8914.nim │ ├── t7109.nim │ ├── tunion.nim │ ├── t11353.nim │ ├── tjshello_stacktrace.nim │ ├── t12672.nim │ ├── tindexdefect.nim │ ├── tcodegendeclvar.nim │ ├── testmagic.nim │ ├── tconsole.nim │ ├── ttryexceptnewsyntax.nim │ ├── t12303.nim │ ├── tjshello.nim │ └── tcodegendeclproc.nim ├── nimble │ ├── nimbleDir │ │ ├── simplePkgs │ │ │ ├── pkgA-0.1.0 │ │ │ │ ├── pkgA.nimble │ │ │ │ └── pkgA │ │ │ │ │ └── module.nim │ │ │ ├── pkgB-#head │ │ │ │ ├── pkgB.nimble │ │ │ │ └── pkgB │ │ │ │ │ └── module.nim │ │ │ ├── pkgB-0.1.0 │ │ │ │ ├── pkgB.nimble │ │ │ │ └── pkgB │ │ │ │ │ └── module.nim │ │ │ ├── pkgC-#aa11 │ │ │ │ ├── pkgC.nimble │ │ │ │ └── pkgC │ │ │ │ │ └── module.nim │ │ │ └── pkgC-#head │ │ │ │ ├── pkgC.nimble │ │ │ │ └── pkgC │ │ │ │ └── module.nim │ │ └── linkedPkgs │ │ │ ├── pkgA-0.1.0 │ │ │ └── pkgA.nimble-link │ │ │ ├── pkgB-#head │ │ │ └── pkgB.nimble-link │ │ │ └── pkgB-0.1.0 │ │ │ └── pkgB.nimble-link │ ├── readme.md │ ├── tnimblepathdollar.nims │ └── tnimblepathdollar_fault.nims ├── parallel │ ├── nim.cfg │ ├── t9691.nim │ └── tsysspawnbadarg.nim ├── template │ ├── m1027a.nim │ ├── m1027b.nim │ ├── i2416.nim │ ├── mlt.nim │ ├── tsighash_regression.nim │ ├── mcan_access_hidden_field.nim │ ├── tparamscope.nim │ ├── template_pragmas.nim │ ├── tredefinition.nim │ ├── twhenintemplates.nim │ ├── t13515.nim │ └── tinnerouterproc.nim ├── clearmsg │ ├── mb.nim │ ├── mc.nim │ ├── tconsttypemismatch.nim │ └── ta.nim ├── errmsgs │ ├── m8794.nim │ ├── tstaticexprnotype.nim │ ├── t18327.nim │ ├── t5282.nim │ ├── t8064.nim │ ├── t18983.nim │ ├── t8610.nim │ ├── temptysetparam.nim │ ├── t10594.nim │ ├── tuncheckedarrayvar.nim │ ├── tnnodeindex.nim │ ├── t8339.nim │ ├── t19882_2.nim │ ├── tnnodeadd.nim │ ├── tcannot_capture_builtin.nim │ ├── tnnodeindexkind.nim │ ├── tcant_overload_by_return_type.nim │ ├── tmultiple_finally.nim │ ├── t6281.nim │ ├── t9908_01.nim │ ├── tgeneral_excepts.nim │ ├── tnested_empty_seq.nim │ ├── t9908_02.nim │ ├── tstaticexprscope.nim │ ├── tstaticresult.nim │ ├── twrongcolon.nim │ ├── t1154.nim │ ├── t10489_a.nim │ ├── t10489_b.nim │ └── t19882.nim ├── navigator │ └── minclude.nim ├── ambsym │ ├── mambsym2.nim │ ├── mambsys2.nim │ ├── mambsys1.nim │ ├── tambsys.nim │ ├── mambsym1.nim │ └── tambsym.nim ├── stylecheck │ ├── fileinfo.nim │ ├── t20397.nim │ ├── t20397_2.nim │ └── t20397_1.nim ├── compilepragma │ ├── test.c │ └── test.nim ├── cpp │ ├── enum.hpp │ ├── foo.c │ ├── tnativesockets.nim │ ├── ttypeinfo2.nim │ ├── tembarrassing_generic_bug.nim │ ├── tgen_prototype_for_importc.nim │ ├── tenum_set.nim │ ├── tterminate_handler.nim │ ├── t9013.nim │ └── t4834.nim ├── ic │ ├── mdefconverter.nim │ ├── config.nims │ ├── mimportsb.nim │ ├── mbaseobj.nim │ ├── mimports.nim │ └── tstdlib_import_changed.nim ├── system │ ├── helpers │ │ └── readall_echo.nim │ ├── tslimsystem.nim │ ├── tgcnone.nim │ ├── tgogc.nim │ └── tatomics1.nim ├── typerel │ ├── ttypedesc_as_genericparam1_orc.nim │ ├── tnoargopenarray.nim │ ├── t8905.nim │ ├── ttypelessemptyset.nim │ ├── tno_int_in_bool_context.nim │ ├── tptrs.nim │ ├── ttypedesc_as_genericparam1.nim │ ├── typredef.nim │ ├── ttypedesc_as_genericparam2.nim │ ├── tclosure_nil_as_default.nim │ ├── t8172.nim │ ├── ttypenovalue.nim │ ├── typedescs.nim │ └── typalias.nim ├── ccgbugs │ ├── m19445.c │ ├── t8616.nim │ ├── pkg8616 │ │ ├── rtarray.nim │ │ └── scheduler.nim │ ├── xoa9578.nim │ ├── tuplecast.nim │ ├── xseq9578.nim │ ├── thtiobj.nim │ ├── tsequence_outoforder.nim │ ├── mstatic_assert.nim │ ├── xarray9578.nim │ ├── tcompile_time_var_at_runtime.nim │ ├── t7079.nim │ ├── t5345.nim │ ├── tcodegenbug_bool.nim │ ├── topenarraycast.nim │ ├── xua9578.nim │ ├── xtuple9578.nim │ ├── tborrowmagic.nim │ ├── tweakopenarray.nim │ ├── t9098.nim │ ├── tarray_equality.nim │ ├── tcapture_static.nim │ ├── tmissing_ccgtrav_unique_type.nim │ ├── tnocodegen_for_compiletime.nim │ ├── tassign_nil_strings.nim │ ├── t8967.nim │ └── t6279.nim ├── dir with space │ └── more spaces │ │ └── mspace.nim ├── importalls │ ├── m2.nim │ ├── mt4b.nim │ ├── mt4.nim │ ├── m3.nim │ ├── mt0.nim │ ├── tmain2.nim │ ├── m4.nim │ └── mt5.nim ├── macros │ ├── mparsefile.nim │ ├── tsame_name_497.nim │ ├── t7454.nim │ ├── tmacroaspragma.nim │ ├── treturnsempty.nim │ └── tisexported.nim ├── sandwich │ ├── helper_module.nim │ ├── generic_library.nim │ └── tmain.nim ├── sets │ ├── t17385.nim │ ├── t2669.nim │ └── m17385.nim ├── concepts │ ├── t5888lib │ │ ├── ca.nim │ │ └── opt.nim │ ├── ttrieconcept.nim │ └── tvarconcept.nim ├── enum │ ├── m16462_1.nim │ ├── m16462_2.nim │ ├── t16462.nim │ ├── mcrossmodule.nim │ ├── tenumitems.nim │ ├── tenum_self.nim │ ├── tenummix.nim │ ├── tenumfieldpragmanoannot.nim │ └── tenumitems2.nim ├── slice │ └── tdistinct.nim ├── generics │ ├── mmodule_same_as_proc.nim │ ├── t8270.nim │ ├── t500.nim │ ├── tbadgenericlambda.nim │ ├── t7141.nim │ ├── t7446.nim │ ├── mclosed_sym.nim │ ├── t2tables.nim │ └── t6637.nim ├── rectest.nim ├── tuples │ ├── twrong_generic_caching.nim │ ├── ttypedesc_in_tuple_a.nim │ ├── ttypedesc_in_tuple_b.nim │ ├── t7012.nim │ ├── twrongtupleaccess.nim │ └── t12892.nim ├── converter │ ├── m18986.nim │ ├── mdontleak.nim │ ├── tconvcolors.nim │ ├── tdontleak.nim │ ├── t18986.nim │ ├── tconverter.nim │ └── ttypeconverter1.nim ├── testdata │ ├── jsonwithextradata.json │ ├── data.csv │ └── csvtest.csv ├── global │ ├── globalaux2.nim │ ├── t5958.nim │ └── tglobalforvar.nim ├── defaultprocparam │ └── mdefaultprocparam.nim ├── exprs │ ├── thighCString.nim │ ├── tstmtexp.nim │ └── tresultwarning.nim ├── types │ ├── t6969.nim │ ├── told_pragma_syntax1.nim │ ├── told_pragma_syntax2.nim │ ├── t6456.nim │ ├── tforwty.nim │ ├── tnontype.nim │ ├── tillegalseqrecursion.nim │ ├── tinfiniterecursion.nim │ ├── tillegaltuplerecursiongeneric2.nim │ ├── tillegaltuplerecursiongeneric.nim │ ├── tillegaltyperecursion2.nim │ ├── tillegaltyperecursion3.nim │ ├── tillegalrecursion3.nim │ ├── tauto_canbe_void.nim │ ├── tfinalobj.nim │ └── tassignemptytuple.nim ├── overload │ ├── importA.nim │ ├── t7416.nim │ ├── tissue966.nim │ └── tnamedparamoverloading.nim ├── parser │ ├── t19662.nim │ ├── twrongcmdsyntax.nim │ ├── ttypecommandcomma.nim │ ├── tifexprs.nim │ ├── ttypecommandindent1.nim │ ├── t12274.nim │ ├── tinvifstmt.nim │ ├── tstatementoperators.nim │ ├── ttypecommandindent2.nim │ ├── ttypecommandindent3.nim │ ├── tinvcolonlocation1.nim │ └── tinvcolonlocation3.nim ├── stmt │ ├── tforloop_underscore.nim │ └── tforloop_tuple_multiple_underscore.nim ├── align │ ├── globalalignas.nim │ └── tillegalalign.nim ├── valgrind │ └── tbasic_valgrind.nim ├── exception │ ├── t20613.nim │ ├── twrongexc.nim │ └── texcsub.nim ├── range │ ├── compilehelpers.nim │ └── tsubrange2.nim ├── bind │ ├── mbind3.nim │ └── tinvalidbindtypedesc.nim ├── concat │ └── tconcat.nim ├── iter │ ├── titerslice.nim │ ├── titer14.nim │ ├── titerautoerr3.nim │ ├── titerautoerr1.nim │ ├── titerautoerr2.nim │ ├── twrongiter.nim │ └── titer5.nim ├── lexer │ ├── tinvalidintegerliteral1.nim │ ├── tinvalidintegerliteral2.nim │ ├── tinvalidintegerliteral3.nim │ ├── tmissingnl.nim │ ├── tintegerliterals.nim │ └── tunderscores.nim ├── proc │ ├── typed.nim │ ├── tlambdapragma.nim │ ├── t17157.nim │ └── tprocredef.nim ├── array │ ├── tidx_lit_err2.nim │ ├── tidx_lit_err3.nim │ └── tidx_lit_err1.nim ├── testament │ ├── t16576.nim │ ├── treject.nim │ └── tinlinemsg.nim ├── views │ ├── tcan_compile_nim.nim │ └── tmust_borrow_from_first_parameter.nim ├── metatype │ └── typedesc_as_value.nim ├── objects │ ├── tillegal_recursion.nim │ ├── m19342.c │ └── tdefaultrangetypescheck.nim ├── overflw │ ├── tdistinct_range.nim │ └── toverflw2.nim ├── discard │ └── tillegaldiscard.nim ├── avr │ └── thello.nim ├── closure │ ├── tinvalidclosure4.nim │ ├── t15594.nim │ ├── tinvalidclosure3.nim │ ├── tinvalidclosure2.nim │ └── tinvalidclosure5.nim ├── deprecated │ └── tconst.nim ├── friends │ ├── mfriends.nim │ └── tfriends.nim ├── openarray │ ├── t8259.nim │ └── topena1.nim ├── stckovfl.nim ├── let │ ├── timportc2.nim │ └── tlet.nim ├── untestable │ ├── gdb │ │ └── gdb_pretty_printer_test_output.txt │ └── network │ │ └── README.md ├── constructors │ ├── t5965_2.nim │ └── t5965_1.nim ├── benchmarks │ └── readme.md ├── showoff │ ├── thtml1.nim │ └── thello2.nim ├── varres │ ├── tvarres3.nim │ ├── tvarres2.nim │ ├── tvartup.nim │ ├── tnewseq_on_result_vart.nim │ └── tvarres1.nim ├── effects │ ├── teffects10.nim │ └── tsidee2.nim ├── gensym │ └── tgensym.nim ├── varstmt │ └── tvardecl.nim ├── rational │ └── trat_float.nim ├── casestmt │ └── tcaseoverlaprange.nim ├── notnil │ └── tnotnil.nim └── lent │ └── tnot_allowed_lent2.nim ├── lib ├── pure │ ├── smtp.nim.cfg │ ├── coro.nimcfg │ ├── nimprof.nim.cfg │ ├── concurrency │ │ └── threadpool.nim.cfg │ ├── asyncdispatch.nim.cfg │ └── async.nim ├── nimhcr.nim.cfg ├── impure │ └── nre │ │ └── .gitignore ├── nimrtl.nim.cfg ├── stdlib.nimble ├── deprecated │ └── pure │ │ ├── future.nim │ │ └── securehash.nim ├── system │ └── formatfloat.nim └── std │ └── vmutils.nim ├── nimdoc ├── testproject │ ├── testproject.nimble │ └── subdir │ │ └── subdir_b │ │ └── utils_helpers.nim └── test_out_index_dot_html │ ├── expected │ └── foo.idx │ └── foo.nim ├── tools ├── ssl_config_parser.nims ├── niminst │ ├── setup.ico │ ├── nim-file.ico │ └── uninstall.ico ├── detect │ ├── .gitignore │ └── timesize.c ├── atlas │ └── tests │ │ ├── grok.nimble │ │ └── sync.nimble ├── nimgrep.nim.cfg └── start.bat ├── icons ├── koch.rc ├── nim.rc ├── koch.ico ├── koch.res ├── nim.ico ├── nim.res ├── koch_icon.o ├── nim_icon.o ├── nim-i386-windows-vcc.res ├── koch-amd64-windows-vcc.res ├── koch-i386-windows-vcc.res └── nim-amd64-windows-vcc.res ├── nimpretty ├── nimpretty.nim.cfg └── tests │ ├── simple4.nim │ └── expected │ └── simple4.nim ├── bin └── empty.txt ├── testament ├── tests │ └── shouldfail │ │ ├── texitcode1.nim │ │ ├── tmaxcodesize.nim │ │ ├── toutput.nim │ │ ├── toutputsub.nim │ │ ├── ttimeout.nim │ │ ├── tnimout.nim │ │ ├── tfile.nim │ │ ├── tccodecheck.nim │ │ ├── terrormsg.nim │ │ ├── tcolumn.nim │ │ ├── tline.nim │ │ ├── tsortoutput.nim │ │ └── treject.nim ├── lib │ └── readme.md └── testament.nim.cfg ├── nimsuggest ├── tests │ ├── fixtures │ │ ├── mdep_v1.nim │ │ ├── mdep_v2.nim │ │ ├── minclude_types.nim │ │ ├── mfakeassert.nim │ │ └── minclude_include.nim │ ├── taccent_highlight.nim │ ├── tv3_import.nim │ ├── tdef_let.nim │ ├── tv3_definition.nim │ ├── top_highlight.nim │ ├── ttemplate_highlight.nim │ ├── tchk_compiles.nim │ ├── tobj_highlight.nim │ ├── tsetter_highlight.nim │ ├── tcallstrlit_highlight.nim │ ├── tsi_highlight.nim │ ├── tcursor_at_end.nim │ └── tno_deref.nim ├── config.nims └── nimsuggest.nimble ├── config ├── rename.rules.cfg └── build_config.txt ├── koch.nim.cfg └── doc └── overview.md /tests/dll/nimhcr_1.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_2.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_1_3.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_2_3.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/newconfig/bar/mfoo.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/newconfig/bar/nim.cfg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/pure/smtp.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:ssl 2 | -------------------------------------------------------------------------------- /tests/import_in_config/other.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/import_in_config/tmain.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/misc/m20456.nims: -------------------------------------------------------------------------------- 1 | echo 123 -------------------------------------------------------------------------------- /tests/newconfig/bar/config.nims: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/newconfig/bar/mfoo.nim.cfg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/newconfig/bar/mfoo.nims: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nimdoc/testproject/testproject.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/arc/testfile.txt: -------------------------------------------------------------------------------- 1 | 1 x 2 | 2 y 3 | -------------------------------------------------------------------------------- /tests/async/hello.txt: -------------------------------------------------------------------------------- 1 | hello humans! -------------------------------------------------------------------------------- /tests/compiles/mstaticlib.nim: -------------------------------------------------------------------------------- 1 | echo 1234 -------------------------------------------------------------------------------- /tests/package/stdlib/stdlib.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/stdlib/tdb.nims: -------------------------------------------------------------------------------- 1 | --styleCheck:off -------------------------------------------------------------------------------- /tests/threads/nim.cfg: -------------------------------------------------------------------------------- 1 | threads:on 2 | -------------------------------------------------------------------------------- /tests/vm/tgorge.bat: -------------------------------------------------------------------------------- 1 | @echo gorge test -------------------------------------------------------------------------------- /lib/pure/coro.nimcfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /lib/pure/nimprof.nim.cfg: -------------------------------------------------------------------------------- 1 | --profiler:on 2 | -------------------------------------------------------------------------------- /tests/arc/nim.cfg: -------------------------------------------------------------------------------- 1 | --sinkInference:on 2 | -------------------------------------------------------------------------------- /tests/dummy.txt: -------------------------------------------------------------------------------- 1 | Just a simple text for test -------------------------------------------------------------------------------- /tests/gc/gctest.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/manyloc/packages/package1/p1.babel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/manyloc/packages/package2/p2.babel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/method/nim.cfg: -------------------------------------------------------------------------------- 1 | multimethods:on 2 | -------------------------------------------------------------------------------- /tests/misc/m15316.nim: -------------------------------------------------------------------------------- 1 | proc foo = (if) 2 | -------------------------------------------------------------------------------- /tests/modules/m9627/a.nim: -------------------------------------------------------------------------------- 1 | var a = 10 2 | -------------------------------------------------------------------------------- /tests/modules/m9627/b.nim: -------------------------------------------------------------------------------- 1 | var b = 9 2 | -------------------------------------------------------------------------------- /tests/stdlib/ttypeinfo.nims: -------------------------------------------------------------------------------- 1 | --styleCheck:off -------------------------------------------------------------------------------- /tools/ssl_config_parser.nims: -------------------------------------------------------------------------------- 1 | --d:ssl 2 | -------------------------------------------------------------------------------- /tests/compilerapi/invalid.nim: -------------------------------------------------------------------------------- 1 | noSuchProc() 2 | -------------------------------------------------------------------------------- /tests/destructor/nim.cfg: -------------------------------------------------------------------------------- 1 | --sinkInference:on 2 | -------------------------------------------------------------------------------- /tests/dll/client.nim.cfg: -------------------------------------------------------------------------------- 1 | --define:useNimRtl 2 | -------------------------------------------------------------------------------- /tests/misc/m20149.nim: -------------------------------------------------------------------------------- 1 | let x = 12 2 | echo x 3 | -------------------------------------------------------------------------------- /tests/modules/mrecmod.nim: -------------------------------------------------------------------------------- 1 | import trecmod 2 | -------------------------------------------------------------------------------- /tests/nimdoc/imp.nim: -------------------------------------------------------------------------------- 1 | proc fn5*() = discard 2 | -------------------------------------------------------------------------------- /tests/package_level_objects/mypackage.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/pragmas/mused2c.nim: -------------------------------------------------------------------------------- 1 | proc baz*() = discard -------------------------------------------------------------------------------- /tests/tools/config.nims: -------------------------------------------------------------------------------- 1 | --d:nimPreviewSlimSystem -------------------------------------------------------------------------------- /icons/koch.rc: -------------------------------------------------------------------------------- 1 | kochicon ICON "koch.ico" 2 | 3 | 4 | -------------------------------------------------------------------------------- /icons/nim.rc: -------------------------------------------------------------------------------- 1 | nimicon ICON "nim.ico" 2 | 3 | 4 | -------------------------------------------------------------------------------- /nimpretty/nimpretty.nim.cfg: -------------------------------------------------------------------------------- 1 | --define: nimpretty 2 | -------------------------------------------------------------------------------- /tests/assert/config.nims: -------------------------------------------------------------------------------- 1 | --excessiveStackTrace:on 2 | -------------------------------------------------------------------------------- /tests/async/nim.cfg: -------------------------------------------------------------------------------- 1 | --experimental:strictEffects 2 | -------------------------------------------------------------------------------- /tests/compiler/tcmdlinecpuamd64.nim.cfg: -------------------------------------------------------------------------------- 1 | cpu:i386 2 | -------------------------------------------------------------------------------- /tests/compiler/tcmdlineoswin.nim.cfg: -------------------------------------------------------------------------------- 1 | os:linux 2 | -------------------------------------------------------------------------------- /tests/constr/a.nim: -------------------------------------------------------------------------------- 1 | type A* = object 2 | a: uint8 -------------------------------------------------------------------------------- /tests/coroutines/tgc.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /tests/coroutines/twait.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /tests/modules/mnamspc1.nim: -------------------------------------------------------------------------------- 1 | import mnamspc2 2 | 3 | -------------------------------------------------------------------------------- /tests/nimdoc/sub/imp.nim: -------------------------------------------------------------------------------- 1 | proc fn4*() = discard 2 | -------------------------------------------------------------------------------- /tests/nimdoc/sub/imp2.nim: -------------------------------------------------------------------------------- 1 | proc fn3*() = discard 2 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter3/various3.nim.cfg: -------------------------------------------------------------------------------- 1 | threads:on -------------------------------------------------------------------------------- /tests/vm/tgorge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "gorge test" -------------------------------------------------------------------------------- /lib/pure/concurrency/threadpool.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/coroutines/texceptions.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /tests/coroutines/titerators.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /tests/js/tdiscard.nim: -------------------------------------------------------------------------------- 1 | import dom 2 | 3 | discard Node() -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgA-0.1.0/pkgA.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgB-#head/pkgB.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgB-0.1.0/pkgB.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgC-#aa11/pkgC.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgC-#head/pkgC.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/parallel/nim.cfg: -------------------------------------------------------------------------------- 1 | threads:on 2 | --experimental 3 | -------------------------------------------------------------------------------- /tests/stdlib/tbitops.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:noUndefinedBitOpts 2 | -------------------------------------------------------------------------------- /tests/template/m1027a.nim: -------------------------------------------------------------------------------- 1 | const version_str* = "mod a" 2 | -------------------------------------------------------------------------------- /tests/template/m1027b.nim: -------------------------------------------------------------------------------- 1 | const version_str* = "mod b" 2 | -------------------------------------------------------------------------------- /tests/tools/compile/config.nims: -------------------------------------------------------------------------------- 1 | switch("path", "$lib/../") -------------------------------------------------------------------------------- /tests/async/tioselectors.nim.cfg: -------------------------------------------------------------------------------- 1 | threads:on -d:threadsafe 2 | -------------------------------------------------------------------------------- /tests/clearmsg/mb.nim: -------------------------------------------------------------------------------- 1 | type 2 | typ* = distinct string 3 | -------------------------------------------------------------------------------- /tests/clearmsg/mc.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | typ* = distinct int 4 | -------------------------------------------------------------------------------- /tests/dll/server.nim.cfg: -------------------------------------------------------------------------------- 1 | --define:useNimRtl 2 | --app:lib 3 | -------------------------------------------------------------------------------- /tests/errmsgs/m8794.nim: -------------------------------------------------------------------------------- 1 | type Foo3* = object 2 | a1: int 3 | -------------------------------------------------------------------------------- /tests/misc/modulea.nim: -------------------------------------------------------------------------------- 1 | type modulea* = object 2 | a: int 3 | -------------------------------------------------------------------------------- /tests/modules/mnotuniquename.nim: -------------------------------------------------------------------------------- 1 | proc flat*() = echo "flat" 2 | -------------------------------------------------------------------------------- /tests/modules/morder_depb.nim: -------------------------------------------------------------------------------- 1 | type Foo* = array[2, byte] 2 | -------------------------------------------------------------------------------- /tests/navigator/minclude.nim: -------------------------------------------------------------------------------- 1 | # An include file. 2 | foo(3) 3 | -------------------------------------------------------------------------------- /tests/template/i2416.nim: -------------------------------------------------------------------------------- 1 | template i2416*() = echo "i2416" 2 | -------------------------------------------------------------------------------- /tests/tools/compile/readme.md: -------------------------------------------------------------------------------- 1 | Test whether the tools compile. -------------------------------------------------------------------------------- /tests/vm/tgorgeex.bat: -------------------------------------------------------------------------------- 1 | @echo gorgeex test 2 | @exit /b 1 3 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_unit.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:useNimRtl 2 | -d:testNimHcr 3 | -------------------------------------------------------------------------------- /tests/manyloc/nake/nakefile.nim.cfg: -------------------------------------------------------------------------------- 1 | path = "dependencies/nake" 2 | -------------------------------------------------------------------------------- /tests/modules/a/utils.nim: -------------------------------------------------------------------------------- 1 | proc burnMem*(a: int) = 2 | discard 3 | -------------------------------------------------------------------------------- /tests/modules/b/utils.nim: -------------------------------------------------------------------------------- 1 | # module b/utils.nim 2 | let x* = 10 3 | -------------------------------------------------------------------------------- /tests/modules/mimport_in_config.nim: -------------------------------------------------------------------------------- 1 | type 2 | DefinedInB* = int 3 | -------------------------------------------------------------------------------- /tests/pragmas/mused2b.nim: -------------------------------------------------------------------------------- 1 | import mused2c 2 | export mused2c 3 | 4 | -------------------------------------------------------------------------------- /lib/pure/asyncdispatch.nim.cfg: -------------------------------------------------------------------------------- 1 | @if nimdoc: 2 | --os:linux 3 | @end 4 | -------------------------------------------------------------------------------- /tests/ambsym/mambsym2.nim: -------------------------------------------------------------------------------- 1 | type 2 | TExport* = enum a, b, c 3 | 4 | -------------------------------------------------------------------------------- /tests/constr/b.nim: -------------------------------------------------------------------------------- 1 | type B* = object 2 | proc A*(a, b: float): B = discard -------------------------------------------------------------------------------- /tests/niminaction/Chapter3/ChatApp/src/client.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/stylecheck/fileinfo.nim: -------------------------------------------------------------------------------- 1 | # fileinfo.nim 2 | type FileInfo* = object -------------------------------------------------------------------------------- /tests/vm/tgorgeex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "gorgeex test" 3 | exit 1 4 | -------------------------------------------------------------------------------- /tests/compilepragma/test.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) { 2 | return a+b; 3 | } 4 | -------------------------------------------------------------------------------- /tests/cpp/enum.hpp: -------------------------------------------------------------------------------- 1 | namespace namespaced { 2 | enum Enum { A, B, C }; 3 | } 4 | -------------------------------------------------------------------------------- /tests/cpp/foo.c: -------------------------------------------------------------------------------- 1 | 2 | char* myFunc() { 3 | return "Hello world"; 4 | } 5 | -------------------------------------------------------------------------------- /tests/ic/mdefconverter.nim: -------------------------------------------------------------------------------- 1 | 2 | converter toBool*(x: int): bool = x != 0 3 | -------------------------------------------------------------------------------- /tests/import_in_config/nim.cfg: -------------------------------------------------------------------------------- 1 | import = "other" 2 | path = "$projectDir" 3 | -------------------------------------------------------------------------------- /tests/manyloc/packages/noconflicts.nim.cfg: -------------------------------------------------------------------------------- 1 | # Mark noconflicts as project file -------------------------------------------------------------------------------- /tests/manyloc/standalone/barebone.nim.cfg: -------------------------------------------------------------------------------- 1 | --os:standalone 2 | --gc:none 3 | -------------------------------------------------------------------------------- /tests/misc/tmodulea.nim: -------------------------------------------------------------------------------- 1 | from modulea import modulea 2 | 3 | #bug #6731 4 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/concurrency.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/parallel_counts.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/race_condition.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/unguarded_access.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on -------------------------------------------------------------------------------- /tests/system/helpers/readall_echo.nim: -------------------------------------------------------------------------------- 1 | when true: 2 | echo(stdin.readAll) 3 | -------------------------------------------------------------------------------- /tests/typerel/ttypedesc_as_genericparam1_orc.nim: -------------------------------------------------------------------------------- 1 | doAssert repr(int) == "int" -------------------------------------------------------------------------------- /tests/vm/tconst_float_as_int.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #4619 3 | const x: float = 0 4 | -------------------------------------------------------------------------------- /bin/empty.txt: -------------------------------------------------------------------------------- 1 | This file keeps several tools from deleting this subdirectory. 2 | -------------------------------------------------------------------------------- /icons/koch.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/koch.ico -------------------------------------------------------------------------------- /icons/koch.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/koch.res -------------------------------------------------------------------------------- /icons/nim.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/nim.ico -------------------------------------------------------------------------------- /icons/nim.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/nim.res -------------------------------------------------------------------------------- /nimdoc/test_out_index_dot_html/expected/foo.idx: -------------------------------------------------------------------------------- 1 | foo index.html#foo foo: foo() 2 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/texitcode1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | exitcode: 1 3 | """ 4 | -------------------------------------------------------------------------------- /tests/ccgbugs/m19445.c: -------------------------------------------------------------------------------- 1 | #include "m19445.h" 2 | 3 | const Foo f = {10, 20, 30, 40}; -------------------------------------------------------------------------------- /tests/dir with space/more spaces/mspace.nim: -------------------------------------------------------------------------------- 1 | proc tenTimes*(x: int): int = 10*x 2 | -------------------------------------------------------------------------------- /tests/importalls/m2.nim: -------------------------------------------------------------------------------- 1 | const bar1* = 2 2 | const bar2 = 2 3 | const bar3 = 3 4 | -------------------------------------------------------------------------------- /tests/macros/mparsefile.nim: -------------------------------------------------------------------------------- 1 | let a = 1 2 | let b = 2 3 | let c = 4 | let d = 4 5 | -------------------------------------------------------------------------------- /tests/misc/99bottles.nim: -------------------------------------------------------------------------------- 1 | # Test if the compiler detects invalid module names 2 | -------------------------------------------------------------------------------- /tests/modules/mnamspc2.nim: -------------------------------------------------------------------------------- 1 | # export an identifier: 2 | var 3 | global*: int 4 | -------------------------------------------------------------------------------- /tests/newconfig/foo2/mfoo2.customext: -------------------------------------------------------------------------------- 1 | doAssert defined(nimscript) 2 | echo "123" 3 | -------------------------------------------------------------------------------- /tests/sandwich/helper_module.nim: -------------------------------------------------------------------------------- 1 | 2 | proc indirectlyMixedIn*: int = 3 | 200 4 | -------------------------------------------------------------------------------- /tests/sets/t17385.nim: -------------------------------------------------------------------------------- 1 | import m17385 2 | 3 | let a = Diff[int]() 4 | a.test() 5 | -------------------------------------------------------------------------------- /icons/koch_icon.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/koch_icon.o -------------------------------------------------------------------------------- /icons/nim_icon.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/nim_icon.o -------------------------------------------------------------------------------- /tests/ccgbugs/t8616.nim: -------------------------------------------------------------------------------- 1 | import pkg8616 / scheduler 2 | 3 | when true: 4 | init() 5 | -------------------------------------------------------------------------------- /tests/concepts/t5888lib/ca.nim: -------------------------------------------------------------------------------- 1 | type 2 | CA* = concept c 3 | c.x is int 4 | 5 | -------------------------------------------------------------------------------- /tests/destructor/helper.nim: -------------------------------------------------------------------------------- 1 | type 2 | MyTestObject*[T] = object 3 | p: ptr T 4 | -------------------------------------------------------------------------------- /tests/enum/m16462_1.nim: -------------------------------------------------------------------------------- 1 | type 2 | Scancode* {.pure.} = enum 3 | SCANCODE_LEFT = 80 -------------------------------------------------------------------------------- /tests/enum/m16462_2.nim: -------------------------------------------------------------------------------- 1 | type 2 | Scancode* {.pure.} = enum 3 | SCANCODE_LEFT = 80 -------------------------------------------------------------------------------- /tests/misc/temptyecho.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "\n" 3 | """ 4 | 5 | echo() 6 | 7 | -------------------------------------------------------------------------------- /tests/newconfig/mymath.nim: -------------------------------------------------------------------------------- 1 | 2 | 3 | proc ln*(x: float): float = 4 | return 0.5 5 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgA-0.1.0/pkgA/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgATest*(): int = 1 -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgB-0.1.0/pkgB/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgBTest*(): int64 = 0 -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgC-#aa11/pkgC/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgCTest*(): int64 = 1 -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/concurrency_regex.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/pragmas/cfunction.c: -------------------------------------------------------------------------------- 1 | 2 | int cfunction(void) { 3 | return NUMBER_HERE; 4 | } 5 | -------------------------------------------------------------------------------- /tests/slice/tdistinct.nim: -------------------------------------------------------------------------------- 1 | type Foo = distinct uint64 2 | const slice = 0 ..< 42.Foo 3 | -------------------------------------------------------------------------------- /tests/tools/second.nim: -------------------------------------------------------------------------------- 1 | import tables 2 | 3 | let dataEx* = {1: 2, 3: 4}.toTable 4 | -------------------------------------------------------------------------------- /lib/nimhcr.nim.cfg: -------------------------------------------------------------------------------- 1 | --app:lib 2 | --threads:on 3 | -d:useNimRtl 4 | -d:createNimHcr 5 | 6 | -------------------------------------------------------------------------------- /tests/arc/bmodule.nim: -------------------------------------------------------------------------------- 1 | import cmodule 2 | 3 | for i in @[1, 2, 3].cycle(): 4 | echo i 5 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_0_5.nim: -------------------------------------------------------------------------------- 1 | 2 | proc getInt*(): int = return 42 # back to the answer... 3 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_1_2.nim: -------------------------------------------------------------------------------- 1 | 2 | import nimhcr_2 3 | 4 | proc f_1*(): int = return f_2() 5 | -------------------------------------------------------------------------------- /tests/ic/config.nims: -------------------------------------------------------------------------------- 1 | when defined(windows): 2 | --tlsEmulation:off 3 | --mm:refc 4 | -------------------------------------------------------------------------------- /tests/manyloc/keineschweine/dependencies/sfml/sfml_vector.nim: -------------------------------------------------------------------------------- 1 | import sfml, math, strutils 2 | -------------------------------------------------------------------------------- /tests/modules/proxy_module.nim: -------------------------------------------------------------------------------- 1 | import definitions 2 | export definitions except p 3 | 4 | -------------------------------------------------------------------------------- /tests/modules/tnotuniquename_dir/mnotuniquename.nim: -------------------------------------------------------------------------------- 1 | 2 | proc nested*() = echo "nested" 3 | -------------------------------------------------------------------------------- /tests/nimble/readme.md: -------------------------------------------------------------------------------- 1 | This directory contains tests for the --nimblePath feature. 2 | 3 | -------------------------------------------------------------------------------- /tests/tools/compile/tkoch.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | include koch -------------------------------------------------------------------------------- /tests/generics/mmodule_same_as_proc.nim: -------------------------------------------------------------------------------- 1 | 2 | proc mmodule_same_as_proc*(x: string) = discard 3 | -------------------------------------------------------------------------------- /tests/misc/thints_off.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--hints:off" 3 | """ 4 | doAssert true 5 | -------------------------------------------------------------------------------- /tests/misc/tparedef.nim: -------------------------------------------------------------------------------- 1 | # This test is now superfluous: 2 | 3 | proc a(a: int) = 4 | return 5 | -------------------------------------------------------------------------------- /tests/modules/b/module_name_clashes.nim: -------------------------------------------------------------------------------- 1 | # See `tmodule_name_clashes` 2 | 3 | type B* = object 4 | -------------------------------------------------------------------------------- /tests/modules/seq.nim: -------------------------------------------------------------------------------- 1 | var seq: seq[int] 2 | var b: seq[float] 3 | 4 | echo seq 5 | echo b 6 | -------------------------------------------------------------------------------- /tests/modules/t8665.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | import treorder 6 | -------------------------------------------------------------------------------- /tests/modules/timport_in_config.nim.cfg: -------------------------------------------------------------------------------- 1 | --import: "strutils" 2 | --import: "mimport_in_config" 3 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgB-#head/pkgB/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgBTest*(): int64 = 0xDEADBEEF -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgC-#head/pkgC/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgCTest*(): int64 = 0xDEADBEEF -------------------------------------------------------------------------------- /tests/package/stdlib/system.nim: -------------------------------------------------------------------------------- 1 | # this module is part of tstdlib_name_not_special 2 | doAssert true -------------------------------------------------------------------------------- /tests/rectest.nim: -------------------------------------------------------------------------------- 1 | # Test the error message 2 | 3 | proc main() = 4 | main() 5 | 6 | main() 7 | -------------------------------------------------------------------------------- /tests/tools/dontmentionme.nim: -------------------------------------------------------------------------------- 1 | {.used.} 2 | 3 | proc nothing* = echo "nothing to see here" 4 | -------------------------------------------------------------------------------- /tests/tuples/twrong_generic_caching.nim: -------------------------------------------------------------------------------- 1 | 2 | import parsecfg 3 | 4 | import asynchttpserver 5 | -------------------------------------------------------------------------------- /nimdoc/test_out_index_dot_html/foo.nim: -------------------------------------------------------------------------------- 1 | proc foo*() = 2 | ## I do foo 3 | echo "foo says hello!" 4 | -------------------------------------------------------------------------------- /tests/arc/t14864.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc $file" 3 | """ 4 | 5 | import bmodule 6 | -------------------------------------------------------------------------------- /tests/ccgbugs/pkg8616/rtarray.nim: -------------------------------------------------------------------------------- 1 | proc head*[T](pp: var array[1,T]): var T = 2 | result = pp[0] 3 | -------------------------------------------------------------------------------- /tests/compiler/tcmdlineclib.nim: -------------------------------------------------------------------------------- 1 | proc test(): int {.importc, cdecl.} 2 | 3 | doAssert test() == 123 4 | -------------------------------------------------------------------------------- /tests/concepts/t5888lib/opt.nim: -------------------------------------------------------------------------------- 1 | import ca 2 | 3 | type 4 | Opt* = object 5 | x*: int 6 | 7 | -------------------------------------------------------------------------------- /tests/converter/m18986.nim: -------------------------------------------------------------------------------- 1 | import std/macros 2 | 3 | converter Lit*(x: uint): NimNode = newLit(x) 4 | -------------------------------------------------------------------------------- /tests/misc/t12480.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'return' not allowed here" 3 | """ 4 | 5 | return -------------------------------------------------------------------------------- /tests/modules/mexport2b.nim: -------------------------------------------------------------------------------- 1 | proc printXyz*() = echo "xyz" 2 | 3 | proc foo*(x: int) = echo "B.foo" 4 | -------------------------------------------------------------------------------- /tests/modules/mforwarded_pure_enum2.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | PureEnum* {.pure.} = enum 4 | x, y, z 5 | -------------------------------------------------------------------------------- /tests/modules/mrange.nim: -------------------------------------------------------------------------------- 1 | 2 | proc range*() = echo "yo" 3 | 4 | proc set*(a: int) = 5 | discard 6 | -------------------------------------------------------------------------------- /tests/package_level_objects/definefoo.nim: -------------------------------------------------------------------------------- 1 | type 2 | Foo* {.package.} = object 3 | x, y: int 4 | -------------------------------------------------------------------------------- /tests/tools/compile/tdeps.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | include tools/deps 6 | -------------------------------------------------------------------------------- /tools/niminst/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/tools/niminst/setup.ico -------------------------------------------------------------------------------- /tests/js/t8231.nim: -------------------------------------------------------------------------------- 1 | import strutils 2 | 3 | doAssert formatSize(2462056448, '.', bpIEC, false) == "2.293GiB" -------------------------------------------------------------------------------- /tests/js/tfloatround.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | 3 4 | ''' 5 | """ 6 | 7 | echo int(22 / 7) 8 | -------------------------------------------------------------------------------- /tests/misc/minit.nim: -------------------------------------------------------------------------------- 1 | # Test the new initialization for modules 2 | write(stdout, "Hello from module! ") 3 | -------------------------------------------------------------------------------- /tests/modules/morder_depa.nim: -------------------------------------------------------------------------------- 1 | 2 | import morder_depb 3 | 4 | proc Foo*(x: int): Foo = discard 5 | 6 | -------------------------------------------------------------------------------- /tests/modules/tutils_ab.nim: -------------------------------------------------------------------------------- 1 | import a/utils as autils, b/utils 2 | 3 | # bug #12420 4 | 5 | burnMem(x) 6 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter7/Tweeter/tests/database_test.nims: -------------------------------------------------------------------------------- 1 | --path:"../src" 2 | #switch("path", "./src") 3 | -------------------------------------------------------------------------------- /tests/testdata/jsonwithextradata.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 123, 3 | "bar": 456 4 | } 5 | 6 | "foobar" 7 | -------------------------------------------------------------------------------- /tools/detect/.gitignore: -------------------------------------------------------------------------------- 1 | pre.c 2 | pre.i 3 | genconsts.c 4 | other_consts.nim 5 | linux_amd64_consts.nim 6 | -------------------------------------------------------------------------------- /tools/niminst/nim-file.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/tools/niminst/nim-file.ico -------------------------------------------------------------------------------- /tools/niminst/uninstall.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/tools/niminst/uninstall.ico -------------------------------------------------------------------------------- /icons/nim-i386-windows-vcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/nim-i386-windows-vcc.res -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/mdep_v1.nim: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | type 7 | Foo* = object 8 | x*, y*: int 9 | -------------------------------------------------------------------------------- /tests/constr/tglobal.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "0" 3 | """ 4 | 5 | # b.nim 6 | import a_module 7 | echo foo() -------------------------------------------------------------------------------- /tests/errmsgs/tstaticexprnotype.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: reject 3 | """ 4 | 5 | let x = static: discard 6 | -------------------------------------------------------------------------------- /tests/global/globalaux2.nim: -------------------------------------------------------------------------------- 1 | import globalaux 2 | 3 | echo "in globalaux2: ", globalInstance[int]().val 4 | 5 | -------------------------------------------------------------------------------- /tests/manyloc/argument_parser/ex_wget.nim.cfg: -------------------------------------------------------------------------------- 1 | # This file exists only to mark 'ex_wget' as the project file 2 | -------------------------------------------------------------------------------- /tests/manyloc/packages/os.nim: -------------------------------------------------------------------------------- 1 | 2 | # Overrides lib/pure/os.nim 3 | 4 | proc yay* = echo "new os.nim" 5 | 6 | -------------------------------------------------------------------------------- /tests/modules/UpperCased.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #5076 3 | 4 | var str*: string 5 | 6 | UpperCased.str = "hello" 7 | -------------------------------------------------------------------------------- /tests/modules/mmodule_same_proc_client.nim: -------------------------------------------------------------------------------- 1 | 2 | proc mmodule_same_proc_client*(x: string): bool = x.len > 0 3 | -------------------------------------------------------------------------------- /tests/pragmas/foobar.nim: -------------------------------------------------------------------------------- 1 | import macros 2 | macro async*(body: untyped): untyped = 3 | return newStmtList() 4 | -------------------------------------------------------------------------------- /tests/stdlib/t9754.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false 3 | """ 4 | 5 | import tmarshal 6 | import tparsesql -------------------------------------------------------------------------------- /tests/stylecheck/t20397.nim: -------------------------------------------------------------------------------- 1 | {.hintAsError[Name]:on.} 2 | var a_b = 1 3 | discard a_b 4 | {.hintAsError[Name]:off.} -------------------------------------------------------------------------------- /tests/template/mlt.nim: -------------------------------------------------------------------------------- 1 | 2 | type Point* = ref object of RootObj 3 | proc `>`*(p1, p2: Point): bool = false 4 | -------------------------------------------------------------------------------- /tests/testdata/data.csv: -------------------------------------------------------------------------------- 1 | Algo_A; Algo_B; Algo_C 2 | 12; 12; 16 3 | 2; 5; 9 4 | 63; 65.3; 90 5 | 0; 1.2; 3 6 | 7 | -------------------------------------------------------------------------------- /tests/tools/compile/tniminst.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | include tools/niminst/niminst -------------------------------------------------------------------------------- /icons/koch-amd64-windows-vcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/koch-amd64-windows-vcc.res -------------------------------------------------------------------------------- /icons/koch-i386-windows-vcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/koch-i386-windows-vcc.res -------------------------------------------------------------------------------- /icons/nim-amd64-windows-vcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/icons/nim-amd64-windows-vcc.res -------------------------------------------------------------------------------- /nimdoc/testproject/subdir/subdir_b/utils_helpers.nim: -------------------------------------------------------------------------------- 1 | proc funWithGenerics*[T, U: SomeFloat](a: T, b: U) = discard 2 | -------------------------------------------------------------------------------- /nimpretty/tests/simple4.nim: -------------------------------------------------------------------------------- 1 | proc readBuffer*(f: AsyncFile, buf: pointer, size: int): Future[int] = 2 | discard 3 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tmaxcodesize.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | maxcodesize: 1 3 | """ 4 | 5 | echo "Hello World" 6 | -------------------------------------------------------------------------------- /tests/arc/cmodule.nim: -------------------------------------------------------------------------------- 1 | iterator cycle*[T](s: openArray[T]): T = 2 | let s = @s 3 | for x in s: 4 | yield x 5 | -------------------------------------------------------------------------------- /tests/ccgbugs/xoa9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testOpenArray*(x: var openArray[mytype]) = 4 | f(x[0].addr) 5 | -------------------------------------------------------------------------------- /tests/constr/t18990.nim: -------------------------------------------------------------------------------- 1 | import a, b 2 | discard A(1f, 1f) # works 3 | proc x(b = A(1f, 1f)) = discard # doesn't work -------------------------------------------------------------------------------- /tests/defaultprocparam/mdefaultprocparam.nim: -------------------------------------------------------------------------------- 1 | 2 | 3 | proc p*(f = (proc(): string = "hi")) = 4 | echo f() 5 | 6 | -------------------------------------------------------------------------------- /tests/modules/mforwarded_pure_enum.nim: -------------------------------------------------------------------------------- 1 | 2 | import mforwarded_pure_enum2 3 | export mforwarded_pure_enum2.PureEnum 4 | -------------------------------------------------------------------------------- /tests/modules/t9627.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "109" 3 | """ 4 | 5 | include m9627 / [a, b] 6 | 7 | echo a, b 8 | -------------------------------------------------------------------------------- /tests/stdlib/tjsontestsuite.nim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pietroppeter/Nim/devel/tests/stdlib/tjsontestsuite.nim -------------------------------------------------------------------------------- /tests/tools/compile/tdetect.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | include tools/detect/detect 6 | -------------------------------------------------------------------------------- /tests/arc/t16458.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--gc:orc --d:useNimRtl" 3 | action: "compile" 4 | """ 5 | 6 | echo 134 -------------------------------------------------------------------------------- /tests/cpp/tnativesockets.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | outputsub: "" 4 | """ 5 | 6 | import nativesockets 7 | -------------------------------------------------------------------------------- /tests/cpp/ttypeinfo2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | """ 4 | # bug #2841 5 | import typeinfo 6 | var tt: Any 7 | -------------------------------------------------------------------------------- /tests/enum/t16462.nim: -------------------------------------------------------------------------------- 1 | import m16462_1 except Scancode 2 | import m16462_2 3 | 4 | # bug #16462 5 | let a = SCANCODE_LEFT -------------------------------------------------------------------------------- /tests/errmsgs/t18327.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "parameter 'n' requires a type" 3 | """ 4 | 5 | proc fn3(n) = discard -------------------------------------------------------------------------------- /tests/importalls/mt4b.nim: -------------------------------------------------------------------------------- 1 | from ./m1 {.all.} as m2 import nil 2 | doAssert not compiles(foo1) 3 | doAssert m2.foo1 == 2 4 | -------------------------------------------------------------------------------- /tests/js/t7127.nim: -------------------------------------------------------------------------------- 1 | doAssertRaises(DivByZeroDefect): discard 1 mod 0 2 | doAssertRaises(DivByZeroDefect): discard 1 div 0 -------------------------------------------------------------------------------- /tests/manyloc/standalone2/tavr.nim.cfg: -------------------------------------------------------------------------------- 1 | --gc:arc 2 | --cpu:avr 3 | --os:standalone 4 | --compileOnly 5 | --threads:off 6 | -------------------------------------------------------------------------------- /tests/vm/tcgemptycallarg.nim: -------------------------------------------------------------------------------- 1 | static: 2 | doAssertRaises(ValueError): 3 | raise newException(ValueError, "Yes") 4 | -------------------------------------------------------------------------------- /nimpretty/tests/expected/simple4.nim: -------------------------------------------------------------------------------- 1 | proc readBuffer*(f: AsyncFile, buf: pointer, size: int): Future[int] = 2 | discard 3 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/toutput.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | done 4 | ''' 5 | """ 6 | 7 | echo "broken" 8 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/toutputsub.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "something else" 3 | """ 4 | 5 | echo "Hello World!" 6 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/ttimeout.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | timeout: "0.1" 3 | """ 4 | 5 | import os 6 | 7 | os.sleep(1000) 8 | -------------------------------------------------------------------------------- /tests/ambsym/mambsys2.nim: -------------------------------------------------------------------------------- 1 | type 2 | TExport* = enum x, y, z # exactly the same type! 3 | 4 | proc foo*(x: int) = discard 5 | -------------------------------------------------------------------------------- /tests/assert/tunittests.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "" 3 | """ 4 | import "../template/utemplates", "../closure/uclosures" 5 | -------------------------------------------------------------------------------- /tests/compiler/samplelib.nim: -------------------------------------------------------------------------------- 1 | # Sample library used by tcmdlineclib.nim 2 | proc test(): int {.cdecl, exportc, dynlib.} = 123 3 | -------------------------------------------------------------------------------- /tests/converter/mdontleak.nim: -------------------------------------------------------------------------------- 1 | 2 | converter toBool(x: uint32): bool = x != 0 3 | # Note: This convertes is not exported! 4 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_0.nim: -------------------------------------------------------------------------------- 1 | 2 | let g_0 = 1000 # new value! but also a "new" global :) 3 | 4 | proc getInt*(): int = return g_0 5 | -------------------------------------------------------------------------------- /tests/errmsgs/t5282.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'x'" 3 | """ 4 | 5 | type x = distinct x 6 | -------------------------------------------------------------------------------- /tests/errmsgs/t8064.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression has no type: values" 3 | """ 4 | import tables 5 | 6 | values -------------------------------------------------------------------------------- /tests/exprs/thighCString.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "5" 3 | """ 4 | let test = cstring("foobar") 5 | 6 | echo high(test) 7 | -------------------------------------------------------------------------------- /tests/ic/mimportsb.nim: -------------------------------------------------------------------------------- 1 | proc fnb1*(): int = 1 2 | proc fnb2*(): int = 2 3 | proc hfnb3(): int = 3 4 | proc hfnb4(): int = 4 5 | -------------------------------------------------------------------------------- /tests/modules/tseq.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false 3 | output: '''@[] 4 | @[] 5 | ''' 6 | """ 7 | 8 | import seq 9 | -------------------------------------------------------------------------------- /tests/system/tslimsystem.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "123" 3 | matrix: "-d:nimPreviewSlimSystem" 4 | """ 5 | 6 | echo 123 -------------------------------------------------------------------------------- /tests/threads/tjsthreads.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp js" 3 | matrix: "--threads:on" 4 | """ 5 | 6 | echo 123 7 | -------------------------------------------------------------------------------- /tests/types/t6969.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'object' for var" 3 | line: 6 4 | """ 5 | 6 | var a: object 7 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_0_6.nim: -------------------------------------------------------------------------------- 1 | 2 | let g_0 = 1000 # new value! but also a "new" global :) 3 | 4 | proc getInt*(): int = return g_0 5 | -------------------------------------------------------------------------------- /tests/js/t11697.nim: -------------------------------------------------------------------------------- 1 | import tables 2 | 3 | var xs: Table[int, Table[int, int]] 4 | 5 | doAssertRaises(KeyError): reset xs[0] 6 | -------------------------------------------------------------------------------- /tests/manyloc/packages/package1/strutils.nim: -------------------------------------------------------------------------------- 1 | 2 | # Overrides lib/pure/os.nim 3 | 4 | proc foo* = echo "package1/strutils" 5 | 6 | -------------------------------------------------------------------------------- /tests/manyloc/packages/package2/strutils.nim: -------------------------------------------------------------------------------- 1 | 2 | # Overrides lib/pure/os.nim 3 | 4 | proc foo* = echo "package2/strutils" 5 | 6 | -------------------------------------------------------------------------------- /tests/misc/t9710.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--debugger:native" 3 | """ 4 | # bug #9710 5 | for i in 1 || 200: 6 | discard i 7 | -------------------------------------------------------------------------------- /tests/modules/definitions.nim: -------------------------------------------------------------------------------- 1 | var v*: int 2 | proc p* = echo "proc p called" 3 | template t* = echo "template t expanded" 4 | 5 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/linkedPkgs/pkgA-0.1.0/pkgA.nimble-link: -------------------------------------------------------------------------------- 1 | ../../simplePkgs/pkgA-0.1.0/pkgA.nimble 2 | ../../simplePkgs/pkgA-0.1.0/ -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/linkedPkgs/pkgB-#head/pkgB.nimble-link: -------------------------------------------------------------------------------- 1 | ../../simplePkgs/pkgB-#head/pkgB.nimble 2 | ../../simplePkgs/pkgB-#head/ -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/linkedPkgs/pkgB-0.1.0/pkgB.nimble-link: -------------------------------------------------------------------------------- 1 | ../../simplePkgs/pkgB-0.1.0/pkgB.nimble 2 | ../../simplePkgs/pkgB-0.1.0/ -------------------------------------------------------------------------------- /tests/stdlib/config.nims: -------------------------------------------------------------------------------- 1 | switch("styleCheck", "usages") 2 | switch("styleCheck", "error") 3 | switch("define", "nimPreviewSlimSystem") -------------------------------------------------------------------------------- /tests/stdlib/nre/optional_nonstrict.nim: -------------------------------------------------------------------------------- 1 | import options 2 | converter option2val*[T](val: Option[T]): T = 3 | return val.get() 4 | -------------------------------------------------------------------------------- /tests/converter/tconvcolors.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "16777215A" 3 | """ 4 | 5 | import colors 6 | 7 | echo int32(colWhite), 'A' 8 | -------------------------------------------------------------------------------- /tests/errmsgs/t18983.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'A'" 3 | """ 4 | 5 | type 6 | A* = A 7 | B = (A,) 8 | -------------------------------------------------------------------------------- /tests/macros/tsame_name_497.nim: -------------------------------------------------------------------------------- 1 | 2 | import macro_bug 3 | 4 | type TObj = object 5 | 6 | proc f(o: TObj) {.macro_bug.} = discard 7 | -------------------------------------------------------------------------------- /tests/misc/mvarious.nim: -------------------------------------------------------------------------------- 1 | # Test a submodule 2 | 3 | #type 4 | # TStringArr = array[0.. *] of string 5 | 6 | proc exportme* = discard 7 | -------------------------------------------------------------------------------- /tests/overload/importA.nim: -------------------------------------------------------------------------------- 1 | type 2 | Field* = object 3 | elemSize*: int 4 | 5 | template `+`*(x: untyped, y: Field): untyped = x 6 | -------------------------------------------------------------------------------- /tests/pragmas/tuserpragma.nim: -------------------------------------------------------------------------------- 1 | 2 | {.pragma: rtl, cdecl, exportc.} 3 | 4 | proc myproc(x, y: int): int {.rtl} = 5 | nil 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/pragmas/warn_module.nim: -------------------------------------------------------------------------------- 1 | 2 | {.warning[UnusedImport]: off.} 3 | 4 | import hashes 5 | 6 | proc test(a: float): float = 7 | a 8 | -------------------------------------------------------------------------------- /tests/types/told_pragma_syntax1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | """ 4 | 5 | type Foo = object {.final.} 6 | -------------------------------------------------------------------------------- /tests/types/told_pragma_syntax2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | """ 4 | 5 | type Bar {.final.} [T] = object 6 | -------------------------------------------------------------------------------- /lib/impure/nre/.gitignore: -------------------------------------------------------------------------------- 1 | # all executables 2 | * 3 | !*/ 4 | !*.* 5 | *.exe 6 | 7 | # Wildcard patterns. 8 | *.swp 9 | nimcache 10 | -------------------------------------------------------------------------------- /nimsuggest/config.nims: -------------------------------------------------------------------------------- 1 | # xxx not sure why this flag isn't needed: switch("processing", "filenames") 2 | switch("filenames", "canonical") 3 | -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/mdep_v2.nim: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | type 7 | Foo* = object 8 | x*, y*: int 9 | z*: string 10 | -------------------------------------------------------------------------------- /tests/compilerapi/exposed.nim: -------------------------------------------------------------------------------- 1 | 2 | proc addFloats*(x, y, z: float): float = 3 | discard "implementation overridden by tcompilerapi.nim" 4 | -------------------------------------------------------------------------------- /tests/constr/a_module.nim: -------------------------------------------------------------------------------- 1 | # a.nim 2 | {.push stackTrace: off.} 3 | proc foo*(): int = 4 | var a {.global.} = 0 5 | result = a 6 | {.pop.} -------------------------------------------------------------------------------- /tests/destructor/tconst_smart_ptr.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | """ 4 | 5 | import const_smart_ptr 6 | 7 | discard test(0) 8 | -------------------------------------------------------------------------------- /tests/errmsgs/t8610.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'typedesc[int]' for const" 3 | """ 4 | ## bug #8610 5 | const Foo = int 6 | -------------------------------------------------------------------------------- /tests/importalls/mt4.nim: -------------------------------------------------------------------------------- 1 | import ./m1 {.all.} except foo1 2 | doAssert foo2 == 2 3 | doAssert declared(foo2) 4 | doAssert not compiles(foo1) 5 | -------------------------------------------------------------------------------- /tests/js/tcsymbol.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--cc:gcc; --cc:tcc" 3 | """ 4 | 5 | doAssert not defined(gcc) 6 | doAssert not defined(tcc) -------------------------------------------------------------------------------- /tests/js/testtojsstr.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output = "И\n" 3 | """ 4 | 5 | let s: string = "И\n" 6 | let cs = s.cstring 7 | 8 | echo $s 9 | -------------------------------------------------------------------------------- /tests/manyloc/named_argument_bug/main.nim.cfg: -------------------------------------------------------------------------------- 1 | # this file only exists to mark 'main.nim' as the main file 2 | 3 | --path:"$projectpath" 4 | -------------------------------------------------------------------------------- /tests/modules/tfowarded_pure_enum.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''z''' 3 | """ 4 | 5 | import mforwarded_pure_enum as t2 6 | 7 | echo z 8 | -------------------------------------------------------------------------------- /tests/parser/t19662.nim: -------------------------------------------------------------------------------- 1 | var i: int # bug #19662 2 | echo i 3 | 4 | discard """ 5 | errormsg: "invalid indentation" 6 | """ -------------------------------------------------------------------------------- /tests/stmt/tforloop_underscore.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: '_'" 3 | """ 4 | 5 | for _ in ["a"]: 6 | echo _ 7 | -------------------------------------------------------------------------------- /tests/testdata/csvtest.csv: -------------------------------------------------------------------------------- 1 | headerField1,headerField2,headerField3 2 | 12,12132,"hallo "" 3 | du" 4 | 1,, 5 | ,2, 6 | ,,3 7 | 1,2,3 8 | 9 | -------------------------------------------------------------------------------- /lib/nimrtl.nim.cfg: -------------------------------------------------------------------------------- 1 | # The RTL.dll needs to be compiled with these options! 2 | 3 | --app:lib 4 | --threads:on 5 | --define:createNimRtl 6 | 7 | -------------------------------------------------------------------------------- /tests/compiler/tgrammar.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "-d:nimTestGrammar" 3 | """ 4 | 5 | import compiler/parser 6 | 7 | checkSameGrammar() 8 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_2_2.nim: -------------------------------------------------------------------------------- 1 | 2 | import hotcodereloading 3 | 4 | proc f_2*(): int = return 1 5 | 6 | afterCodeReload: 7 | echo " 2: after!" 8 | -------------------------------------------------------------------------------- /tests/js/t20233.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "yes" 3 | """ 4 | case 1.0 5 | of 1.0..2.0, 4.0: echo "yes" 6 | of 3.0: discard 7 | else: echo "no" -------------------------------------------------------------------------------- /tests/js/temptyseq.nim: -------------------------------------------------------------------------------- 1 | # #12671 2 | 3 | proc foo = 4 | var x: seq[int] 5 | doAssertRaises(IndexDefect): 6 | inc x[0] 7 | 8 | foo() 9 | -------------------------------------------------------------------------------- /tests/manyloc/keineschweine/server/nim.cfg: -------------------------------------------------------------------------------- 1 | debugger = off 2 | path = ".." 3 | path = "../genpacket" 4 | path = "../helpers" 5 | define = NoSFML 6 | -------------------------------------------------------------------------------- /tests/misc/m15955.nim: -------------------------------------------------------------------------------- 1 | proc add*(a, b: int): int {.cdecl, exportc.} = 2 | a + b 3 | proc sub*(a, b: int): int {.cdecl, exportc.} = 4 | a - b -------------------------------------------------------------------------------- /tests/modules/tincludeas.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Cannot use 'as' in 'include'." 3 | line: 6 4 | """ 5 | 6 | include foobar as foo 7 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter2/no_iterator.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | line: 6 4 | """ 5 | 6 | for i in 5: 7 | echo i 8 | -------------------------------------------------------------------------------- /tests/tuples/ttypedesc_in_tuple_a.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "typedesc not allowed as tuple field." 3 | """ 4 | 5 | var bar = (a: int, b: 1) 6 | -------------------------------------------------------------------------------- /tests/vm/tnilref.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "attempt to access a nil address" 3 | """ 4 | 5 | static: 6 | var s: ref int 7 | s[] = 1 -------------------------------------------------------------------------------- /config/rename.rules.cfg: -------------------------------------------------------------------------------- 1 | TSignedInt 2 | TUnsignedInt 3 | TOrdinal 4 | TReal 5 | TNumber 6 | TEnum 7 | TObject 8 | TResult 9 | TOpenArray 10 | -------------------------------------------------------------------------------- /tests/align/globalalignas.nim: -------------------------------------------------------------------------------- 1 | var myglobal1* {.align(128).}: int32 2 | var myglobal2* {.align(128).}: int32 3 | var myglobal3* {.align(128).}: int32 4 | -------------------------------------------------------------------------------- /tests/ambsym/mambsys1.nim: -------------------------------------------------------------------------------- 1 | import mambsys2 # import TExport 2 | 3 | type 4 | TExport* = enum x, y, z 5 | 6 | proc foo*(x: int) = 7 | discard 8 | -------------------------------------------------------------------------------- /tests/enum/mcrossmodule.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | OtherEnum* = enum 4 | Success, Failed, More 5 | 6 | proc some*(x: OtherEnum): bool = x == Success 7 | -------------------------------------------------------------------------------- /tests/ic/mbaseobj.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | Base* = ref object of RootObj 4 | s*: string 5 | 6 | method m*(b: Base) {.base.} = 7 | echo "Base ", b.s 8 | -------------------------------------------------------------------------------- /tests/misc/mbetterrun.nim: -------------------------------------------------------------------------------- 1 | const mbetterrunVal {.strdefine.} = "" 2 | static: echo "compiling: " & mbetterrunVal 3 | echo "running: " & mbetterrunVal 4 | -------------------------------------------------------------------------------- /tests/misc/tnewderef.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: 3 3 | 4 | """ 5 | 6 | var x: ref int 7 | new(x) 8 | x[] = 3 9 | 10 | echo x[] 11 | 12 | -------------------------------------------------------------------------------- /tests/misc/tsamename2.nim: -------------------------------------------------------------------------------- 1 | proc fooBar*()=discard 2 | proc fooBar2*()=discard 3 | proc callFun*[Fun](processPattern: Fun) = 4 | processPattern() 5 | -------------------------------------------------------------------------------- /tests/modules/mexport2a.nim: -------------------------------------------------------------------------------- 1 | 2 | import mexport2b 3 | export mexport2b 4 | proc printAbc*() = echo "abc" 5 | 6 | proc foo*() = echo "A.foo" 7 | 8 | -------------------------------------------------------------------------------- /tests/system/tgcnone.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--gc:none -d:useMalloc --threads:off" 3 | """ 4 | # bug #15617 5 | let x = 4 6 | doAssert x == 4 7 | -------------------------------------------------------------------------------- /tests/template/tsighash_regression.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | exitcode: 1 3 | outputsub: "0" 4 | """ 5 | 6 | import tconfusinglocal 7 | 8 | fail "foo" 9 | -------------------------------------------------------------------------------- /tests/valgrind/tbasic_valgrind.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | valgrind: true 3 | cmd: "nim c --gc:destructors $file" 4 | """ 5 | 6 | echo "hello world" 7 | -------------------------------------------------------------------------------- /tests/vm/t19199.nim: -------------------------------------------------------------------------------- 1 | # bug #19199 2 | proc mikasa(x: float) = doAssert x == 42 3 | 4 | static: 5 | mikasa 42.uint.float 6 | mikasa 42.uint.float 7 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tnimout.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: "Hello World!" 3 | action: compile 4 | """ 5 | 6 | static: 7 | echo "something else" 8 | -------------------------------------------------------------------------------- /tests/arc/t20456.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check $file" 3 | action: "compile" 4 | """ 5 | 6 | when not defined(gcOrc): 7 | {.error: "orc".} 8 | -------------------------------------------------------------------------------- /tests/arc/tamodule.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | abcde 4 | 0 5 | ''' 6 | cmd: "nim c --gc:arc $file" 7 | """ 8 | 9 | import amodule 10 | -------------------------------------------------------------------------------- /tests/errmsgs/temptysetparam.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot infer the type of parameter 'x'" 3 | line: 5 4 | """ 5 | proc a(x = {}) = discard 6 | -------------------------------------------------------------------------------- /tests/exception/t20613.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "; --panics:on" 3 | """ 4 | 5 | func test = 6 | if 0 > 10: 7 | raiseAssert "hey" 8 | test() 9 | -------------------------------------------------------------------------------- /tests/js/t7534.nim: -------------------------------------------------------------------------------- 1 | proc f(x: int): int = 2 | result = case x 3 | of 1: 2 4 | elif x == 2: 3 5 | else: 1 6 | 7 | doAssert 2 == f(f(f(f(1)))) 8 | -------------------------------------------------------------------------------- /tests/js/tmodify_cstring.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cstring doesn't support `[]=` operator" 3 | """ 4 | 5 | var x = cstring"abcd" 6 | x[0] = 'x' 7 | -------------------------------------------------------------------------------- /tests/misc/tinc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | file: "tinc.nim" 4 | line: 8 5 | """ 6 | var x = 0 7 | 8 | inc(x+1) 9 | -------------------------------------------------------------------------------- /tests/nimdoc/readme.md: -------------------------------------------------------------------------------- 1 | ## links 2 | * $nim/nimdoc/tester.nim: tests html validation 3 | * $nim/tests/nimdoc/: tests `runnableExamples` + `nim doc` logic 4 | -------------------------------------------------------------------------------- /tests/range/compilehelpers.nim: -------------------------------------------------------------------------------- 1 | template accept(e) = 2 | static: assert(compiles(e)) 3 | 4 | template reject(e) = 5 | static: assert(not compiles(e)) 6 | -------------------------------------------------------------------------------- /tests/tuples/ttypedesc_in_tuple_b.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Mixing types and values in tuples is not allowed." 3 | """ 4 | 5 | var bar = (int, 1) 6 | -------------------------------------------------------------------------------- /tests/types/t6456.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type \'ptr void\' is not allowed" 3 | line: 6 4 | """ 5 | 6 | proc foo(x: ptr void) = 7 | discard 8 | -------------------------------------------------------------------------------- /tests/bind/mbind3.nim: -------------------------------------------------------------------------------- 1 | # Module A 2 | var 3 | lastId = 0 4 | 5 | template genId*: int = 6 | bind lastId 7 | inc(lastId) 8 | lastId 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/concepts/ttrieconcept.nim: -------------------------------------------------------------------------------- 1 | import libs/[trie_database, trie] 2 | 3 | proc takeDb(d: TrieDatabase) = discard 4 | var mdb: MemDB 5 | 6 | takeDb(mdb) 7 | 8 | -------------------------------------------------------------------------------- /tests/enum/tenumitems.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "attempting to call routine: 'items'" 3 | line: 7 4 | """ 5 | 6 | type a = enum b,c,d 7 | a.items() 8 | -------------------------------------------------------------------------------- /tests/generics/t8270.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot instantiate: \'T\'" 3 | line: 6 4 | """ 5 | 6 | proc m[T](x: T): int = discard 7 | echo [m] 8 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter2/no_seq_type.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot infer the type of the sequence" 3 | line: 6 4 | """ 5 | 6 | var list = @[] 7 | -------------------------------------------------------------------------------- /tests/stylecheck/t20397_2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'a_b' should be: 'aB'" 3 | matrix: "--styleCheck:error" 4 | """ 5 | 6 | var a_b = 1 7 | discard a_b -------------------------------------------------------------------------------- /tests/types/tforwty.nim: -------------------------------------------------------------------------------- 1 | # Test 13: forward types 2 | 3 | type 4 | PSym = ref TSym 5 | 6 | TSym = object 7 | next: PSym 8 | 9 | var s: PSym 10 | -------------------------------------------------------------------------------- /lib/pure/async.nim: -------------------------------------------------------------------------------- 1 | when defined(js): 2 | import asyncjs 3 | export asyncjs 4 | else: 5 | import asyncmacro, asyncfutures 6 | export asyncmacro, asyncfutures 7 | -------------------------------------------------------------------------------- /nimsuggest/tests/taccent_highlight.nim: -------------------------------------------------------------------------------- 1 | proc `$$$`#[!]# 2 | 3 | discard """ 4 | $nimsuggest --tester $file 5 | >highlight $1 6 | highlight;;skProc;;1;;6;;3 7 | """ 8 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tfile.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'undefined'" 3 | file: "notthisfile.nim" 4 | """ 5 | 6 | echo undefined 7 | -------------------------------------------------------------------------------- /tests/concat/tconcat.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "DabcD" 3 | """ 4 | 5 | const 6 | x = "abc" 7 | 8 | var v = "D" & x & "D" 9 | 10 | echo v 11 | 12 | -------------------------------------------------------------------------------- /tests/generics/t500.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | type 6 | TTest = tuple[x: range[0..80], y: range[0..25]] 7 | 8 | let x: TTest = (2, 23) 9 | -------------------------------------------------------------------------------- /tests/global/t5958.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'a'" 3 | line: 9 4 | """ 5 | 6 | static: 7 | var a = 1 8 | 9 | echo a 10 | -------------------------------------------------------------------------------- /tests/js/t14570.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | 18 4 | ''' 5 | """ 6 | 7 | type A = range[15 .. 30] 8 | 9 | let a: A = 18 10 | 11 | echo ord(a) 12 | -------------------------------------------------------------------------------- /tests/manyloc/named_argument_bug/tri_engine/config.nim: -------------------------------------------------------------------------------- 1 | when defined(doublePrecision): 2 | type 3 | TR* = float64 4 | else: 5 | type 6 | TR* = float32 7 | -------------------------------------------------------------------------------- /tests/misc/tnewsets.nim: -------------------------------------------------------------------------------- 1 | # new test for sets: 2 | 3 | const elem = ' ' 4 | 5 | var s: set[char] = {elem} 6 | assert(elem in s and 'a' not_in s and 'c' not_in s ) 7 | -------------------------------------------------------------------------------- /tests/modules/mexportb.nim: -------------------------------------------------------------------------------- 1 | # module B 2 | type TMyObject* = object 3 | 4 | const xyz* = 13 5 | 6 | proc q*(x: int): int = 6 7 | proc q*(x: string): string = "8" 8 | -------------------------------------------------------------------------------- /tests/modules/tuppercased.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "hello" 3 | """ 4 | 5 | import UpperCased 6 | 7 | # stress normalization rules: 8 | echo Upper_Cased.str 9 | -------------------------------------------------------------------------------- /tests/parser/twrongcmdsyntax.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: '''in expression '4 2': identifier expected, but found '4''' 3 | line: 6 4 | """ 5 | 6 | echo 4 +2 7 | -------------------------------------------------------------------------------- /tests/sandwich/generic_library.nim: -------------------------------------------------------------------------------- 1 | 2 | proc libraryFunc*[T](x: T) = 3 | mixin mixedIn, indirectlyMixedIn 4 | echo mixedIn() 5 | echo indirectlyMixedIn() 6 | 7 | -------------------------------------------------------------------------------- /tests/sets/t2669.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot convert 6 to range 1..5(int8)" 3 | line: 6 4 | """ 5 | 6 | var c: set[range[1i8..5i8]] = {1i8, 2i8, 6i8} 7 | -------------------------------------------------------------------------------- /tests/system/tgogc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | disabled: "windows" 3 | cmd: "nim c --gc:go $file" 4 | action: "compile" 5 | """ 6 | # bug #11447 7 | echo "Go GC test" 8 | -------------------------------------------------------------------------------- /tests/typerel/tnoargopenarray.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | import db_sqlite 6 | 7 | var db: DbConn 8 | exec(db, sql"create table blabla()") 9 | -------------------------------------------------------------------------------- /lib/stdlib.nimble: -------------------------------------------------------------------------------- 1 | 2 | version = system.NimVersion 3 | author = "Dominik Picheta" 4 | description = "Nim's standard library." 5 | license = "MIT" 6 | -------------------------------------------------------------------------------- /nimsuggest/tests/tv3_import.nim: -------------------------------------------------------------------------------- 1 | import tv#[!]#3 2 | 3 | discard """ 4 | $nimsuggest --v3 --tester $file 5 | >def $1 6 | def skModule tv3 */tv3.nim 1 0 "" 100 7 | """ 8 | -------------------------------------------------------------------------------- /tests/concepts/tvarconcept.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "5" 3 | """ 4 | 5 | # bug #2346, bug #2404 6 | 7 | import mvarconcept 8 | 9 | echo randomInt(5) 10 | -------------------------------------------------------------------------------- /tests/errmsgs/t10594.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression has no address" 3 | line: 7 4 | """ 5 | 6 | template foo(v: varargs[int]) = addr v 7 | foo(1, 2) 8 | -------------------------------------------------------------------------------- /tests/iter/titerslice.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''2 3 | 3 4 | 4''' 5 | """ 6 | 7 | var t1 = @["1", "2", "3", "4"] 8 | for t in t1[1..3]: 9 | echo t 10 | -------------------------------------------------------------------------------- /tests/lexer/tinvalidintegerliteral1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid number" 3 | file: "tinvalidintegerliteral1.nim" 4 | line: 7 5 | """ 6 | 7 | echo 0b 8 | -------------------------------------------------------------------------------- /tests/lexer/tinvalidintegerliteral2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid number" 3 | file: "tinvalidintegerliteral2.nim" 4 | line: 7 5 | """ 6 | 7 | echo 0x 8 | -------------------------------------------------------------------------------- /tests/macros/t7454.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression has no type:" 3 | line: 8 4 | """ 5 | 6 | macro p(t: typedesc): typedesc = 7 | discard 8 | var a: p(int) 9 | -------------------------------------------------------------------------------- /tests/misc/tcharinc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "1" 3 | """ 4 | 5 | var c = '\0' 6 | while true: 7 | if c == '\xFF': break 8 | inc c 9 | 10 | echo "1" 11 | -------------------------------------------------------------------------------- /tests/modules/mopaque.nim: -------------------------------------------------------------------------------- 1 | type 2 | TLexer* {.final.} = object 3 | line*: int 4 | filename*: string 5 | buffer: cstring 6 | 7 | proc noProcVar*(): int = 18 8 | -------------------------------------------------------------------------------- /tests/parser/ttypecommandcomma.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | line: 8 4 | column: 19 5 | """ 6 | 7 | type 8 | Foo = call(1, 2), 3: 9 | 4 -------------------------------------------------------------------------------- /tests/proc/typed.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'typed' is only allowed in templates and macros" 3 | line: 6 4 | """ 5 | 6 | proc fun(x:typed)=discard 7 | fun(10) 8 | -------------------------------------------------------------------------------- /tests/tuples/t7012.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'Node'" 3 | """ 4 | 5 | type Node[T] = tuple 6 | next: ref Node[T] 7 | var n: Node[int] -------------------------------------------------------------------------------- /tests/types/tnontype.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expected type, but got: 3" 3 | """ 4 | 5 | type 6 | Foo = (block: 7 | int) 8 | 9 | Bar = 3 10 | -------------------------------------------------------------------------------- /tools/atlas/tests/grok.nimble: -------------------------------------------------------------------------------- 1 | version = "0.0.4" 2 | author = "disruptek" 3 | description = "don't read too much into it" 4 | license = "MIT" 5 | requires "nim >= 1.0.0" 6 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tccodecheck.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | ccodecheck: "baz" 3 | """ 4 | 5 | proc foo(): void {.exportc: "bar".}= 6 | echo "Hello World" 7 | 8 | foo() 9 | -------------------------------------------------------------------------------- /tests/ccgbugs/tuplecast.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #4345 3 | 4 | # only needs to compile 5 | proc f(): tuple[a, b: uint8] = (1'u8, 2'u8) 6 | 7 | let a, b = f() 8 | let c = cast[int](b) 9 | -------------------------------------------------------------------------------- /tests/ccgbugs/xseq9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testSeq*(x: var seq[mytype]) = 4 | f(x[0].addr) 5 | 6 | proc testSeq2*(x: var ptr seq[mytype]) = 7 | f(x[0].addr) 8 | -------------------------------------------------------------------------------- /tests/iter/titer14.nim: -------------------------------------------------------------------------------- 1 | proc f() = 2 | var s: seq[int] 3 | iterator a(): int = 4 | for x in s: yield x 5 | 6 | iterator b(): int = 7 | for x in a(): yield x 8 | -------------------------------------------------------------------------------- /tests/js/t8821.nim: -------------------------------------------------------------------------------- 1 | 2 | proc isInt32(i: int): bool = 3 | case i 4 | of 1 .. 70000: 5 | return true 6 | else: 7 | return false 8 | 9 | doAssert isInt32(1) == true -------------------------------------------------------------------------------- /tests/manyloc/keineschweine/server/dirserver_settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "network":"lamenet", 3 | "port":2049, 4 | "zones":[ 5 | {"name":"alphazone","key":"skittles"} 6 | ] 7 | } -------------------------------------------------------------------------------- /tests/misc/mspellsuggest.nim: -------------------------------------------------------------------------------- 1 | proc fooBar4*(a: int) = discard 2 | var fooBar9* = 0 3 | 4 | var fooCar* = 0 5 | type FooBar* = int 6 | type FooCar* = int 7 | type GooBa* = int 8 | -------------------------------------------------------------------------------- /tests/misc/tgcregions.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:regions $file" 3 | """ 4 | 5 | # issue #12597 6 | # it just tests that --gc:regions compiles. Nothing else. :'( 7 | -------------------------------------------------------------------------------- /tests/misc/tnolen.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | line: 8 4 | """ 5 | 6 | # please finally disallow Len(3) 7 | 8 | echo len(3) 9 | -------------------------------------------------------------------------------- /tests/sandwich/tmain.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''100 3 | 200''' 4 | """ 5 | 6 | import 7 | module_using_generic_library 8 | 9 | makeUseOfLibrary "test" 10 | -------------------------------------------------------------------------------- /tests/stylecheck/t20397_1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--styleCheck:off" 3 | """ 4 | 5 | {.hintAsError[Name]:on.} 6 | var a_b = 1 7 | discard a_b 8 | {.hintAsError[Name]:off.} -------------------------------------------------------------------------------- /tests/typerel/t8905.nim: -------------------------------------------------------------------------------- 1 | type 2 | Foo[T] = distinct seq[T] 3 | Bar[T] = object 4 | 5 | proc newFoo[T](): Foo[T] = Foo[T](newSeq[T]()) 6 | 7 | var x = newFoo[Bar[int]]() 8 | -------------------------------------------------------------------------------- /tests/array/tidx_lit_err2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expected ordinal value for array index, got '\"string\"'" 3 | line: 5 4 | """ 5 | let x = ["string": 0, "index": 1] 6 | -------------------------------------------------------------------------------- /tests/converter/tdontleak.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''5''' 3 | joinable: false 4 | """ 5 | 6 | import mdontleak 7 | # bug #19213 8 | 9 | let a = 5'u32 10 | echo a 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tuncheckedarrayvar.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: ''' 3 | invalid type: 'UncheckedArray[uint8]' for var 4 | ''' 5 | """ 6 | 7 | var byteUA: UncheckedArray[uint8] 8 | -------------------------------------------------------------------------------- /tests/importalls/m3.nim: -------------------------------------------------------------------------------- 1 | # xxx use below naming convention in other test files: p: public, h: hidden 2 | const m3p1* = 2 3 | const m3h2 = 2 4 | const m3h3 = 3 5 | const m3h4 = 4 6 | -------------------------------------------------------------------------------- /tests/misc/tjoinable.nim: -------------------------------------------------------------------------------- 1 | # checks that megatest allows duplicate names, see also `tests/testament/tjoinable.nim` 2 | doAssert defined(testing) 3 | doAssert defined(nimMegatest) 4 | -------------------------------------------------------------------------------- /tests/package/tstdlib_name_not_special.nim: -------------------------------------------------------------------------------- 1 | # Test whether a another package named 'stdlib' can be imported and used. 2 | # This caused a crash in the past. 3 | import stdlib/system -------------------------------------------------------------------------------- /tests/parser/tifexprs.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | 1 4 | ''' 5 | """ 6 | 7 | var a, b: int 8 | let x = if a > b: 9 | 0 10 | else: 1 11 | 12 | echo x 13 | -------------------------------------------------------------------------------- /tests/system/tatomics1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp js" 3 | """ 4 | 5 | var x = 10 6 | atomicInc(x) 7 | doAssert x == 11 8 | atomicDec(x) 9 | doAssert x == 10 10 | -------------------------------------------------------------------------------- /tests/testament/t16576.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix:"-d:nimTest_t16576" 3 | """ 4 | 5 | # bug #16576 6 | doAssert defined(nimTest_t16576) 7 | doAssert not defined(nimMegatest) 8 | -------------------------------------------------------------------------------- /tests/typerel/ttypelessemptyset.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "internal error: invalid kind for lastOrd(tyEmpty)" 3 | """ 4 | var q = false 5 | discard (if q: {} else: {}) 6 | 7 | -------------------------------------------------------------------------------- /tests/types/tillegalseqrecursion.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'CyclicSeq'" 3 | """ 4 | # issue #13715 5 | type 6 | CyclicSeq = seq[ref CyclicSeq] 7 | -------------------------------------------------------------------------------- /tests/views/tcan_compile_nim.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check --hints:on --experimental:strictFuncs --experimental:views compiler/nim.nim" 3 | action: "compile" 4 | """ 5 | -------------------------------------------------------------------------------- /nimsuggest/tests/tdef_let.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | $nimsuggest --tester $file 3 | >def $1 4 | def;;skLet;;tdef_let.intVar;;int;;$file;;7;;4;;"";;100 5 | """ 6 | 7 | let int#[!]#Var = 10 8 | -------------------------------------------------------------------------------- /tests/ccgbugs/pkg8616/scheduler.nim: -------------------------------------------------------------------------------- 1 | import rtarray 2 | 3 | type 4 | T = tuple[x:int] 5 | 6 | var 7 | arr: array[1,T] 8 | 9 | proc init*() = 10 | discard head(arr) 11 | -------------------------------------------------------------------------------- /tests/ccgbugs/thtiobj.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc" 3 | targets: "c cpp" 4 | """ 5 | 6 | import typeinfo 7 | 8 | var x = "" 9 | discard (getPointer(toAny(x))) 10 | -------------------------------------------------------------------------------- /tests/ccgbugs/tsequence_outoforder.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''@[2]''' 3 | """ 4 | 5 | # bug #9684 6 | 7 | var s2 = @[2, 2] 8 | 9 | s2 = @[s2.len] 10 | 11 | echo s2 12 | -------------------------------------------------------------------------------- /tests/destructor/objFile.nim: -------------------------------------------------------------------------------- 1 | type Obj* = object 2 | v*: int 3 | 4 | proc `=destroy`(this: var Obj) = 5 | echo "igotdestroyed" 6 | this.v = -1 7 | 8 | var test* = Obj(v: 42) 9 | -------------------------------------------------------------------------------- /tests/js/t8914.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | @[42] 4 | @[24, 42] 5 | ''' 6 | """ 7 | 8 | var x = @[42,4242] 9 | x.delete(1) 10 | echo x 11 | x.insert(24) 12 | echo x 13 | -------------------------------------------------------------------------------- /tests/manyloc/standalone2/tavr.nim: -------------------------------------------------------------------------------- 1 | # bug #16404 2 | 3 | proc printf(frmt: cstring) {.varargs, header: "", cdecl.} 4 | 5 | var x = 0 6 | inc x 7 | printf("hi %ld\n", x+4777) 8 | -------------------------------------------------------------------------------- /tests/metatype/typedesc_as_value.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'typedesc[int]' for var" 3 | """ 4 | 5 | 6 | var x = int 7 | 8 | echo x 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/modules/torder_dep.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''[0, 0]''' 3 | """ 4 | 5 | import morder_depb 6 | import morder_depa 7 | 8 | # bug #11187 9 | 10 | echo Foo(3) 11 | -------------------------------------------------------------------------------- /tests/nimdoc/sub/mmain.nim: -------------------------------------------------------------------------------- 1 | {.warning[UnusedImport]: off.} 2 | 3 | import ../imp as impa 4 | import imp as impb 5 | import imp2 6 | 7 | proc fn1*() = discard 8 | proc fn2*() = discard 9 | -------------------------------------------------------------------------------- /tests/overload/t7416.nim: -------------------------------------------------------------------------------- 1 | type 2 | Foo[T] = object 3 | IntFoo = Foo[int] 4 | 5 | proc bar(b: object|tuple) = discard 6 | proc bar(b: IntFoo) = discard 7 | 8 | var f: IntFoo 9 | bar(f) -------------------------------------------------------------------------------- /tests/parser/ttypecommandindent1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | line: 9 4 | column: 3 5 | """ 6 | 7 | type 8 | Foo = call x, y, z: 9 | abc 10 | -------------------------------------------------------------------------------- /tests/pragmas/t4384.nim: -------------------------------------------------------------------------------- 1 | macro testMacro(body: untyped): untyped = discard 2 | macro testMacro(s: string, body: untyped): untyped = discard 3 | proc foo() {.testMacro: "foo".} = discard 4 | -------------------------------------------------------------------------------- /tests/stdlib/osproctest.nim: -------------------------------------------------------------------------------- 1 | # This is test program for the osproc module. 2 | 3 | import os 4 | 5 | echo getCurrentDir() 6 | 7 | for i in 1..paramCount(): 8 | echo paramStr(i) 9 | -------------------------------------------------------------------------------- /tests/stdlib/toserrors.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | import std/oserrors 6 | 7 | let x1 = osLastError() 8 | raiseOSError(x1) 9 | echo osErrorMsg(x1) 10 | -------------------------------------------------------------------------------- /tests/stdlib/tterminal.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | import terminal, colors 5 | 6 | styledEcho fgColor, colRed, "Test" 7 | styledEcho bgColor, colBlue, "Test" 8 | -------------------------------------------------------------------------------- /tests/typerel/tno_int_in_bool_context.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'bool'" 3 | line: 6 4 | """ 5 | 6 | if 1: 7 | echo "wtf?" 8 | -------------------------------------------------------------------------------- /tests/typerel/tptrs.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'ptr int'" 3 | line: 8 4 | """ 5 | 6 | var 7 | n: int16 8 | p: ptr int = addr n 9 | -------------------------------------------------------------------------------- /tests/align/tillegalalign.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check $options $file" 3 | errormsg: "power of two expected" 4 | """ 5 | 6 | proc foobar() = 7 | let something {.align(33).} = 123 8 | -------------------------------------------------------------------------------- /tests/ccgbugs/mstatic_assert.nim: -------------------------------------------------------------------------------- 1 | {.emit:""" 2 | NIM_STATIC_ASSERT(sizeof(bool) == 1, ""); 3 | #warning "foo2" 4 | NIM_STATIC_ASSERT(sizeof(bool) == 2, ""); 5 | #warning "foo3" 6 | """.} 7 | -------------------------------------------------------------------------------- /tests/ccgbugs/xarray9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testArray*(x: var array[3,mytype]) = 4 | f(x[0].addr) 5 | 6 | proc testArray2*(x: var ptr array[3,mytype]) = 7 | f(x[0].addr) 8 | -------------------------------------------------------------------------------- /tests/clearmsg/tconsttypemismatch.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | file: "tconsttypemismatch.nim" 4 | line: 7 5 | """ 6 | # bug #2252 7 | const foo: int = 1000 / 30 8 | -------------------------------------------------------------------------------- /tests/js/t7109.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Closure iterators are not supported by JS backend!" 3 | """ 4 | 5 | iterator iter*(): int {.closure.} = 6 | yield 3 7 | 8 | var x = iter 9 | -------------------------------------------------------------------------------- /tests/modules/a/module_name_clashes.nim: -------------------------------------------------------------------------------- 1 | # See `tmodule_name_clashes` 2 | 3 | import ../b/module_name_clashes 4 | type A* = object 5 | b*: B 6 | 7 | proc print*(a: A) = 8 | echo repr a 9 | -------------------------------------------------------------------------------- /tests/modules/mexporta.nim: -------------------------------------------------------------------------------- 1 | # module A 2 | import mexportb 3 | export mexportb.TMyObject, mexportb.xyz 4 | 5 | export mexportb.q 6 | 7 | proc `$`*(x: TMyObject): string = "my object" 8 | 9 | -------------------------------------------------------------------------------- /tests/modules/texplicit_system_import.nim: -------------------------------------------------------------------------------- 1 | import system except `+` 2 | 3 | discard """ 4 | errormsg: "undeclared identifier: '+'" 5 | line: 9 6 | """ 7 | 8 | 9 | echo 4+5 10 | -------------------------------------------------------------------------------- /tests/objects/tillegal_recursion.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "inheritance only works with non-final objects" 3 | line: 7 4 | """ 5 | # bug #1691 6 | type 7 | Foo = ref object of Foo 8 | -------------------------------------------------------------------------------- /tests/stdlib/tintsets.nim: -------------------------------------------------------------------------------- 1 | import ./mintsets 2 | 3 | block: # bug https://github.com/nim-lang/Nim/pull/15564#issuecomment-729878104 4 | # related to bug #11167 5 | test1() 6 | test2() 7 | -------------------------------------------------------------------------------- /tests/stdlib/tterminal_15874.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --app:console $file" 3 | action: "compile" 4 | """ 5 | 6 | import terminal 7 | 8 | writeStyled("hello", {styleBright}) 9 | -------------------------------------------------------------------------------- /tests/testament/treject.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "reject" 3 | """ 4 | 5 | # this line does not compile, so the test should pass, since action="reject" 6 | let x: int = "type mismatch" 7 | -------------------------------------------------------------------------------- /tests/types/tinfiniterecursion.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'XIM'" 3 | line: 8 4 | """ 5 | 6 | type 7 | XIM* = ptr XIM 8 | XIMProc* = proc (a2: XIM) 9 | -------------------------------------------------------------------------------- /tools/nimgrep.nim.cfg: -------------------------------------------------------------------------------- 1 | # don't use --gc:refc because of bug 2 | # https://github.com/nim-lang/Nim/issues/14138 . 3 | # --gc:orc and --gc:markandsweep work well. 4 | --threads:on --gc:orc 5 | -------------------------------------------------------------------------------- /tests/arc/t18971.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc $file" 3 | """ 4 | 5 | type MyObj = ref object 6 | 7 | var o = MyObj() 8 | proc x: var MyObj = o 9 | 10 | var o2 = x() 11 | -------------------------------------------------------------------------------- /tests/cpp/tembarrassing_generic_bug.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | cmd: "nim cpp --threads:on $file" 4 | """ 5 | 6 | # bug #5142 7 | 8 | var ci: Channel[int] 9 | ci.open 10 | -------------------------------------------------------------------------------- /tests/errmsgs/tnnodeindex.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "index 5 not in 0 .. 2" 3 | line: 7 4 | """ 5 | import macros 6 | macro t(x: untyped): untyped = 7 | result = x[5] 8 | t([1, 2, 3]) 9 | -------------------------------------------------------------------------------- /tests/generics/tbadgenericlambda.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "nested proc can have generic parameters only when" 3 | line: 6 4 | """ 5 | 6 | let x = proc (x, y: auto): auto = x + y 7 | 8 | -------------------------------------------------------------------------------- /tests/js/tunion.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "`{.union.}` is not implemented for js backend." 3 | """ 4 | 5 | type Foo {.union.} = object 6 | as_bytes: array[8, int8] 7 | data: int64 8 | -------------------------------------------------------------------------------- /tests/misc/tfib.nim: -------------------------------------------------------------------------------- 1 | 2 | iterator fibonacci(): int = 3 | var a = 0 4 | var b = 1 5 | while true: 6 | yield a 7 | var c = b 8 | b = a 9 | a = a + c 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/overflw/tdistinct_range.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "Error: unhandled exception: over- or underflow [OverflowDefect]" 3 | exitcode: "1" 4 | """ 5 | var x: distinct range[0..5] 6 | dec(x) -------------------------------------------------------------------------------- /tests/pragmas/tpushexperimental.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''0 1 3 | 1 2 4 | 2 3 5 | 0 1 6 | 1 2 7 | 2 3 8 | 3 5''' 9 | """ 10 | 11 | import mpushexperimental 12 | 13 | main(12) 14 | -------------------------------------------------------------------------------- /tests/stdlib/t15663.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc $file" 3 | output: "Test" 4 | """ 5 | 6 | import std/widestrs 7 | 8 | let ws = newWideCString("Test") 9 | echo ws 10 | -------------------------------------------------------------------------------- /tests/typerel/ttypedesc_as_genericparam1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc" 3 | errormsg: "type mismatch: got " 4 | line: 7 5 | """ 6 | # bug #3079, #1146 7 | echo repr(int) -------------------------------------------------------------------------------- /tools/detect/timesize.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) { 6 | printf("%ld\n", sizeof(time_t)); 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /koch.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:booting 2 | 3 | @if openbsd: 4 | # because openbsd getAppFilename was broken in v0.20.0 5 | # workaround see https://github.com/nim-lang/Nim/pull/14291 6 | --lib:lib 7 | @end 8 | -------------------------------------------------------------------------------- /tests/arc/t17173.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--gc:refc; --gc:arc" 3 | """ 4 | 5 | import std/strbasics 6 | 7 | 8 | var a = " vhellov " 9 | strip(a) 10 | doAssert a == "vhellov" 11 | -------------------------------------------------------------------------------- /tests/ccgbugs/tcompile_time_var_at_runtime.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "1\n2\n2\n3" 3 | """ 4 | var a {.compileTime.} = 1 5 | 6 | echo a 7 | a = 2 8 | echo a 9 | echo a 10 | a = 3 11 | echo a -------------------------------------------------------------------------------- /tests/destructor/tglobaldestructor.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: '''nim c --gc:arc $file''' 3 | output: '''(v: 42) 4 | igotdestroyed''' 5 | """ 6 | 7 | import objFile 8 | 9 | echo test 10 | -------------------------------------------------------------------------------- /tests/discard/tillegaldiscard.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal discard" 3 | line: 9 4 | """ 5 | 6 | proc pop[T](arg: T): T = 7 | echo arg 8 | 9 | discard tillegaldiscard.pop 10 | -------------------------------------------------------------------------------- /tests/generics/t7141.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot instantiate: \'T\'" 3 | line: 6 4 | """ 5 | 6 | proc foo[T](x: T) = 7 | discard 8 | 9 | var fun = if true: foo else: foo 10 | -------------------------------------------------------------------------------- /tests/macros/tmacroaspragma.nim: -------------------------------------------------------------------------------- 1 | import macros 2 | 3 | macro foo(x: untyped): untyped = 4 | echo treerepr(callsite()) 5 | result = newNimNode(nnkStmtList) 6 | 7 | proc zoo() {.foo.} = echo "hi" 8 | -------------------------------------------------------------------------------- /tests/modules/timport_in_config.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''hallo''' 3 | joinable: false 4 | """ 5 | 6 | # bug #9978, #9994 7 | var x: DefinedInB 8 | 9 | echo "hi".replace("i", "allo") 10 | -------------------------------------------------------------------------------- /tests/modules/tmodule_same_proc.nim: -------------------------------------------------------------------------------- 1 | 2 | import mmodule_same_proc 3 | 4 | # importing baz causes the error not to trigger 5 | #import baz 6 | 7 | # bug #11188 8 | 9 | discard "foo".bar() 10 | -------------------------------------------------------------------------------- /tests/proc/tlambdapragma.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid pragma: exportc" 3 | """ 4 | 5 | let _ = proc () {.exportc.} = 6 | # this would previously cause a codegen error 7 | discard 8 | -------------------------------------------------------------------------------- /tools/start.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM COLOR 0A 3 | chcp 65001 4 | SET NIMPATH=%~dp0\.. 5 | SET PATH=%NIMPATH%\bin;%NIMPATH%\dist\mingw\bin;%PATH% 6 | cd %NIMPATH% 7 | cmd 8 | 9 | 10 | -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/minclude_types.nim: -------------------------------------------------------------------------------- 1 | # types used by minclude_* (import or include), to find with def in include 2 | 3 | type 4 | Greet* = object 5 | greeting*: string 6 | subject*: string -------------------------------------------------------------------------------- /tests/ambsym/tambsys.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "" 3 | """ 4 | # Test ambiguous symbols 5 | 6 | import mambsys1, mambsys2 7 | 8 | var 9 | v: mambsys1.TExport 10 | mambsys2.foo(3) #OUT 11 | -------------------------------------------------------------------------------- /tests/avr/thello.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --compileOnly --os:standalone --exceptions:quirky -d:noSignalHandler -d:danger --threads:off $file" 3 | action: "compile" 4 | """ 5 | 6 | echo "hi" 7 | -------------------------------------------------------------------------------- /tests/ccgbugs/t7079.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: run 3 | targets: '''c js''' 4 | """ 5 | 6 | import math 7 | let x = -0.0 8 | doAssert classify(x) == fcNegZero 9 | doAssert classify(1 / -0.0) == fcNegInf -------------------------------------------------------------------------------- /tests/closure/tinvalidclosure4.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal capture 'v'" 3 | line: 7 4 | """ 5 | 6 | proc outer(v: int) = 7 | proc b {.nimcall.} = echo v 8 | b() 9 | outer(5) 10 | -------------------------------------------------------------------------------- /tests/converter/t18986.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "Found a 0" 3 | """ 4 | 5 | import m18986 except Lit 6 | import std/macros 7 | 8 | # bug #18986 9 | var x = 0.uint 10 | echo "Found a ", x 11 | -------------------------------------------------------------------------------- /tests/deprecated/tconst.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: ''' 3 | tconst.nim(8, 9) Warning: abcd; foo is deprecated [Deprecated] 4 | ''' 5 | """ 6 | 7 | const foo* {.deprecated: "abcd".} = 42 8 | discard foo 9 | -------------------------------------------------------------------------------- /tests/errmsgs/t8339.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'seq[float]'" 3 | line: 8 4 | """ 5 | 6 | import sequtils 7 | 8 | var x: seq[float] = @[1].mapIt(it) 9 | -------------------------------------------------------------------------------- /tests/method/tmethod.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "\'method\' needs a parameter that has an object type" 3 | file: "tmethod.nim" 4 | line: 7 5 | """ 6 | 7 | method m(i: int): int = 8 | return 5 9 | -------------------------------------------------------------------------------- /tests/modules/timportexcept.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: '%'" 3 | line: 9 4 | """ 5 | 6 | import strutils except `%` 7 | 8 | # doesn't work 9 | echo "$1" % "abc" 10 | -------------------------------------------------------------------------------- /tests/modules/trecmod.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "recursive module dependency detected" 3 | file: "mrecmod.nim" 4 | line: 1 5 | disabled: true 6 | """ 7 | # recursive module 8 | import mrecmod 9 | -------------------------------------------------------------------------------- /tests/proc/t17157.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'untyped' is only allowed in templates and macros or magic procs" 3 | """ 4 | 5 | template something(op: proc (v: untyped): void): void = 6 | discard 7 | -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/mfakeassert.nim: -------------------------------------------------------------------------------- 1 | # Template for testing defs 2 | 3 | template fakeAssert*(cond: untyped, msg: string = "") = 4 | ## template to allow def lookup testing 5 | if not cond: quit(1) 6 | -------------------------------------------------------------------------------- /tests/array/tidx_lit_err3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "size of array exceeds range of index type 'range 2147483646..2147483647(int32)' by 1 elements" 3 | line: 5 4 | """ 5 | echo [high(int32)-1: 1, 2, 3] 6 | -------------------------------------------------------------------------------- /tests/ccgbugs/t5345.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: true 3 | """ 4 | 5 | proc cmpx(d: int): bool {.inline.} = d > 0 6 | 7 | proc abc[C](cx: C, d: int) = 8 | echo cx(d) 9 | 10 | abc(cmpx, 10) 11 | -------------------------------------------------------------------------------- /tests/errmsgs/t19882_2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot instantiate: 'A[T]'; the object's generic parameters cannot be inferred and must be explicitly given" 3 | """ 4 | type A[T] = object 5 | var a = A() -------------------------------------------------------------------------------- /tests/errmsgs/tnnodeadd.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot add to node kind: nnkInt8Lit" 3 | line: 7 4 | """ 5 | import macros 6 | macro t(x: untyped): untyped = 7 | x.add(newEmptyNode()) 8 | t(38'i8) 9 | -------------------------------------------------------------------------------- /tests/exprs/tstmtexp.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression '5' is of type 'int literal(5)' and has to be used (or discarded)" 3 | file: "tstmtexp.nim" 4 | line: 8 5 | """ 6 | # Test 3 7 | 8 | 1+4 9 | -------------------------------------------------------------------------------- /tests/friends/mfriends.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | TMyObj = object 4 | x: int 5 | 6 | proc gen*[T](): T = 7 | var d: TMyObj 8 | # access private field here 9 | d.x = 3 10 | result = d.x 11 | 12 | -------------------------------------------------------------------------------- /tests/iter/titerautoerr3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot infer the return type of 'bar'" 3 | line: 6 4 | """ 5 | 6 | iterator bar(): auto = 7 | discard 8 | for t in bar(): 9 | discard 10 | -------------------------------------------------------------------------------- /tests/js/t11353.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | {} 4 | {} 5 | ''' 6 | """ 7 | 8 | proc foo() = 9 | var bar: set[int16] = {} 10 | echo bar 11 | bar.incl(1) 12 | 13 | foo() 14 | foo() 15 | -------------------------------------------------------------------------------- /tests/js/tjshello_stacktrace.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "Hello World" 3 | maxcodesize: 4500 4 | ccodecheck: "!@'function'" 5 | """ 6 | 7 | import jsconsole 8 | 9 | console.log "Hello World" 10 | -------------------------------------------------------------------------------- /tests/openarray/t8259.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'openArray[int]' for result" 3 | line: 6 4 | """ 5 | 6 | proc foo(a: openArray[int]):auto = a 7 | echo foo(toOpenArray([1, 2], 0, 2)) 8 | -------------------------------------------------------------------------------- /tests/stckovfl.nim: -------------------------------------------------------------------------------- 1 | # To test stack overflow message 2 | 3 | proc over(a: int): int = 4 | if a >= 10: 5 | assert false 6 | return 7 | result = over(a+1)+5 8 | 9 | Echo($over(0)) 10 | 11 | -------------------------------------------------------------------------------- /doc/overview.md: -------------------------------------------------------------------------------- 1 | ============================= 2 | Nim Documentation Overview 3 | ============================= 4 | 5 | :Author: Andreas Rumpf 6 | :Version: |nimversion| 7 | 8 | .. include:: docs.md 9 | 10 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/terrormsg.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "wrong error message" 3 | line: 9 4 | column: 6 5 | """ 6 | 7 | # test should fail because the line directive is wrong 8 | echo undeclared 9 | -------------------------------------------------------------------------------- /tests/closure/t15594.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "The variable name cannot be `result`!" 3 | """ 4 | 5 | import sugar 6 | 7 | proc begin(): int = 8 | capture result: 9 | echo 1+1 10 | result 11 | -------------------------------------------------------------------------------- /tests/compiler/t12684.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check --hints:off --warnings:off $file" 3 | errormsg: "undeclared identifier: 'Undeclared'" 4 | """ 5 | 6 | var x: Undeclared 7 | import compiler/nimeval 8 | -------------------------------------------------------------------------------- /tests/exprs/tresultwarning.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: "tresultwarning.nim(6, 7) Warning: Special variable 'result' is shadowed. [ResultShadowed]" 3 | """ 4 | 5 | proc test(): string = 6 | var result = "foo" 7 | -------------------------------------------------------------------------------- /tests/js/t12672.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "" 3 | """ 4 | 5 | proc foo = 6 | var x: seq[seq[int]] 7 | for row in x.mitems: 8 | let i = 1 9 | echo row 10 | inc row[i-1] 11 | 12 | foo() 13 | -------------------------------------------------------------------------------- /tests/modules/tnotuniquename.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''nested 3 | flat''' 4 | """ 5 | 6 | import mnotuniquename 7 | import tnotuniquename_dir/mnotuniquename as nun 8 | 9 | nested() 10 | flat() 11 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter2/explicit_discard.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "has to be used (or discarded)" 3 | line: 7 4 | """ 5 | 6 | proc myProc(name: string): string = "Hello " & name 7 | myProc("Dominik") 8 | -------------------------------------------------------------------------------- /tests/parser/t12274.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false 3 | """ 4 | 5 | var s: seq[int] 6 | s.add block: 7 | let i = 1 8 | i 9 | s.add try: 10 | 2 11 | except: 12 | 3 13 | doAssert s == @[1, 2] 14 | -------------------------------------------------------------------------------- /tests/stdlib/tstrtabs.nims: -------------------------------------------------------------------------------- 1 | import std/[strtabs, assertions] 2 | 3 | static: 4 | let t = {"name": "John", "city": "Monaco"}.newStringTable 5 | doAssert "${name} lives in ${city}" % t == "John lives in Monaco" 6 | -------------------------------------------------------------------------------- /tests/template/mcan_access_hidden_field.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | Foo* = object 4 | fooa, foob: int 5 | 6 | proc createFoo*(a, b: int): Foo = Foo(fooa: a, foob: b) 7 | 8 | template geta*(f: Foo): untyped = f.fooa 9 | -------------------------------------------------------------------------------- /tests/vm/t17039.nim: -------------------------------------------------------------------------------- 1 | type 2 | Obj1 = object 3 | case kind: bool 4 | of false: 5 | field: seq[int] 6 | else: discard 7 | 8 | static: 9 | var obj1 = Obj1() 10 | obj1.field.add(@[]) 11 | -------------------------------------------------------------------------------- /lib/deprecated/pure/future.nim: -------------------------------------------------------------------------------- 1 | ## This module is a deprecated alias for the `sugar` module. Deprecated since 0.19.0. 2 | 3 | {.deprecated: "Use the new 'sugar' module instead".} 4 | 5 | import sugar 6 | export sugar 7 | -------------------------------------------------------------------------------- /lib/deprecated/pure/securehash.nim: -------------------------------------------------------------------------------- 1 | ## This module is a deprecated alias for the `sha1` module. Deprecated since 0.18.1. 2 | 3 | {.deprecated: "use `std/sha1` instead".} 4 | 5 | import "../std/sha1" 6 | export sha1 7 | -------------------------------------------------------------------------------- /lib/system/formatfloat.nim: -------------------------------------------------------------------------------- 1 | when not defined(nimPreviewSlimSystem): 2 | import std/formatfloat 3 | export formatfloat 4 | {.deprecated: "use `std/formatfloat`".} 5 | else: 6 | {.error: "use `std/formatfloat`".} 7 | -------------------------------------------------------------------------------- /testament/lib/readme.md: -------------------------------------------------------------------------------- 1 | This directory contains helper files used by several tests, to avoid 2 | code duplication, akin to a std extension tailored for testament. 3 | 4 | Some of these could later migrate to stdlib. 5 | -------------------------------------------------------------------------------- /tests/ccgbugs/tcodegenbug_bool.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | """ 3 | 4 | # issue #13798 5 | {.emit:""" 6 | #include 7 | void fun(bool a){} 8 | """.} 9 | 10 | proc fun(a: bool) {.importc.} 11 | fun(true) 12 | -------------------------------------------------------------------------------- /tests/ccgbugs/topenarraycast.nim: -------------------------------------------------------------------------------- 1 | proc foo[T](s: var openArray[T]): T = 2 | for x in s: result += x 3 | 4 | proc bar(xyz: var seq[int]) = 5 | doAssert 6 == (seq[int](xyz)).foo() 6 | 7 | var t = @[1,2,3] 8 | bar(t) 9 | -------------------------------------------------------------------------------- /tests/ccgbugs/xua9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testUncheckedArray*(x: var UncheckedArray[mytype]) = 4 | f(x[0].addr) 5 | 6 | proc testUncheckedArray2*(x: var ptr UncheckedArray[mytype]) = 7 | f(x[0].addr) 8 | -------------------------------------------------------------------------------- /tests/constr/tnocompiletimefunclambda.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "request to generate code for .compileTime proc: :anonymous" 3 | """ 4 | 5 | let a = func(a: varargs[int]) {.compileTime, closure.} = 6 | discard a[0] -------------------------------------------------------------------------------- /tests/enum/tenum_self.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "1 can't be converted to ErrorFoo" 3 | """ 4 | 5 | 6 | type 7 | Foo = enum 8 | Bar = 0.Foo 9 | 10 | ErrorFoo = enum 11 | eBar = 1.ErrorFoo 12 | -------------------------------------------------------------------------------- /tests/enum/tenummix.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | file: "tenummix.nim" 4 | line: 11 5 | """ 6 | 7 | type 8 | TE1 = enum eA, eB 9 | TE2 = enum eC, eD 10 | 11 | assert eA != eC 12 | -------------------------------------------------------------------------------- /tests/errmsgs/tcannot_capture_builtin.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'+' is a built-in and cannot be used as a first-class procedure" 3 | line: 8 4 | """ 5 | 6 | # bug #2050 7 | 8 | let v: proc (a, b: int): int = `+` 9 | -------------------------------------------------------------------------------- /tests/misc/mjsondoc.nim: -------------------------------------------------------------------------------- 1 | proc doSomething*(x, y: int): int = 2 | ## do something 3 | x + y 4 | 5 | const 6 | a* = 1 ## echo 1234 7 | b* = "test" 8 | 9 | type 10 | MyEnum* = enum 11 | foo, bar 12 | -------------------------------------------------------------------------------- /tests/parser/tinvifstmt.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | line: 9 4 | column: 3 5 | """ 6 | 7 | if true: 8 | echo "a" 9 | elif: 10 | echo "b" 11 | else: 12 | echo "c" 13 | -------------------------------------------------------------------------------- /tests/parser/tstatementoperators.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: ''' 3 | Infix 4 | Ident "from" 5 | Ident "a" 6 | Ident "b" 7 | ''' 8 | """ 9 | 10 | from macros import dumpTree 11 | 12 | dumpTree(a from b) -------------------------------------------------------------------------------- /tests/parser/ttypecommandindent2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | line: 10 4 | column: 5 5 | """ 6 | 7 | type 8 | Foo = call x, y, z: 9 | abc 10 | do: 11 | def 12 | -------------------------------------------------------------------------------- /tests/pragmas/tsym_as_pragma.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #3171 3 | 4 | template newDataWindow(): untyped = 5 | let eventClosure = proc (closure: pointer): bool {.closure, cdecl.} = 6 | discard 7 | 8 | newDataWindow() 9 | -------------------------------------------------------------------------------- /tests/proc/tprocredef.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "redefinition of \'foo\'" 3 | file: "tprocredef.nim" 4 | line: 8 5 | """ 6 | 7 | proc foo(a: int, b: string) = discard 8 | proc foo(a: int, b: string) = discard 9 | -------------------------------------------------------------------------------- /tests/typerel/typredef.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type \'Uint8\'" 3 | file: "typredef.nim" 4 | line: 7 5 | """ 6 | type 7 | Uint8 = Uint8 #ERROR_MSG illegal recursion in type 'Uint8' 8 | -------------------------------------------------------------------------------- /tests/types/tillegaltuplerecursiongeneric2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'TPearl'" 3 | """ 4 | 5 | type 6 | TPearl[T] = tuple 7 | next: TPearl[T] 8 | 9 | var x: TPearl[int] 10 | -------------------------------------------------------------------------------- /tests/vm/tclosureiterator.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Closure iterators are not supported by VM!" 3 | """ 4 | 5 | iterator iter*(): int {.closure.} = 6 | yield 3 7 | 8 | static: 9 | var x = iter 10 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcsubimmint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var x = int64.low 8 | discard x - 1 9 | doAssert false 10 | p() 11 | -------------------------------------------------------------------------------- /tests/vm/twrongconst.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot evaluate at compile time: x" 3 | line: 7 4 | """ 5 | 6 | var x: array[100, char] 7 | template foo : char = x[42] 8 | 9 | const myConst = foo 10 | -------------------------------------------------------------------------------- /tests/ccgbugs/xtuple9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testTuple*(x: var tuple[a:mytype,b:mytype,c:mytype]) = 4 | f(x[0].addr) 5 | 6 | proc testTuple2*(x: var ptr tuple[a:mytype,b:mytype,c:mytype]) = 7 | f(x[0].addr) 8 | -------------------------------------------------------------------------------- /tests/compilepragma/test.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''44''' 3 | joinable: "false" 4 | """ 5 | 6 | {.compile: "test.c".} 7 | 8 | proc foo(a, b: cint): cint {.importc: "foo", cdecl.} 9 | 10 | echo foo(40, 4) 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tnnodeindexkind.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot set child of node kind: nnkStrLit" 3 | line: 7 4 | """ 5 | import macros 6 | macro t(x: untyped): untyped = 7 | x[0] = newEmptyNode() 8 | t("abc") 9 | -------------------------------------------------------------------------------- /tests/iter/titerautoerr1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'string'" 3 | line: 8 4 | """ 5 | 6 | iterator a(): auto {.closure.} = 7 | if true: return "str" 8 | yield 1 9 | -------------------------------------------------------------------------------- /tests/iter/titerautoerr2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'int literal(1)'" 3 | line: 8 4 | """ 5 | 6 | iterator b(): auto {.closure.} = 7 | yield 1 8 | if true: return "str" 9 | -------------------------------------------------------------------------------- /tests/js/tindexdefect.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "unhandled exception: index 10000 not in 0 .. 0 [IndexDefect]" 3 | exitcode: 1 4 | joinable: false 5 | """ 6 | 7 | var s = ['a'] 8 | let z = s[10000] == 'a' 9 | echo z -------------------------------------------------------------------------------- /tests/let/timportc2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'let' symbol requires an initialization" 3 | line: "7" 4 | """ 5 | 6 | # Test that this still works when not annotated with importc 7 | let test: cint 8 | echo test 9 | -------------------------------------------------------------------------------- /tests/lexer/tinvalidintegerliteral3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "0O5 is an invalid int literal; For octal literals use the '0o' prefix." 3 | file: "tinvalidintegerliteral3.nim" 4 | line: 7 5 | """ 6 | 7 | echo 0O5 8 | -------------------------------------------------------------------------------- /tests/openarray/topena1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type" 3 | file: "topena1.nim" 4 | line: 9 5 | """ 6 | # Tests a special bug 7 | 8 | var 9 | x: ref openArray[string] #ERROR_MSG invalid type 10 | -------------------------------------------------------------------------------- /tests/stdlib/t7686.nim: -------------------------------------------------------------------------------- 1 | import std/strutils 2 | import std/assertions 3 | 4 | type 5 | MyEnum = enum 6 | A, 7 | a 8 | 9 | doAssert parseEnum[MyEnum]("A") == A 10 | doAssert parseEnum[MyEnum]("a") == a 11 | -------------------------------------------------------------------------------- /tests/types/tillegaltuplerecursiongeneric.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'RefTree'" 3 | """ 4 | 5 | type 6 | RefTree[T] = ref tuple[le, ri: RefTree[T]; data: T] 7 | RefTreeInt = RefTree[int] 8 | -------------------------------------------------------------------------------- /tests/types/tillegaltyperecursion2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'Executor'" 3 | line: 8 4 | """ 5 | # bug reported by PR #5637 6 | type 7 | Executor[N] = Executor[N] 8 | var e: Executor[int] 9 | -------------------------------------------------------------------------------- /tests/untestable/gdb/gdb_pretty_printer_test_output.txt: -------------------------------------------------------------------------------- 1 | Loading Nim Runtime support. 2 | NimEnumPrinter: lookup global symbol 'NTI__z9cu80OJCfNgw9bUdzn5ZEzw_ failed for tyEnum_MyOtherEnum__z9cu80OJCfNgw9bUdzn5ZEzw. 3 | 8 4 | -------------------------------------------------------------------------------- /nimsuggest/tests/tv3_definition.nim: -------------------------------------------------------------------------------- 1 | 2 | let foo = 30 3 | let bar = foo + fo#[!]#o + foo 4 | 5 | discard """ 6 | $nimsuggest --v3 --tester $file 7 | >def $1 8 | def skLet tv3_definition.foo int $file 2 4 "" 100 9 | """ 10 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tcolumn.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'undeclared'" 3 | line: 9 4 | column: 7 5 | """ 6 | 7 | # test should fail because the line directive is wrong 8 | echo undeclared 9 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tline.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'undeclared'" 3 | line: 10 4 | column: 6 5 | """ 6 | 7 | # test should fail because the line directive is wrong 8 | echo undeclared 9 | -------------------------------------------------------------------------------- /tests/clearmsg/ta.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | line: 12 4 | """ 5 | 6 | import mb, mc 7 | 8 | proc test(testing: mb.typ) = 9 | discard 10 | 11 | var s: mc.typ 12 | test(s) 13 | -------------------------------------------------------------------------------- /tests/constructors/t5965_2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "incorrect object construction syntax" 3 | file: "t5965_2.nim" 4 | line: 10 5 | """ 6 | 7 | type Foo = object 8 | a: int 9 | 10 | discard Foo(a: 1, 2) 11 | -------------------------------------------------------------------------------- /tests/enum/tenumfieldpragmanoannot.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "annotation to deprecated not supported here" 3 | line: 8 4 | """ 5 | 6 | type 7 | A = enum 8 | a {.deprecated: "njshd".} 9 | 10 | var v1 = a 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tcant_overload_by_return_type.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "overloaded 'x' leads to ambiguous calls" 3 | line: 9 4 | """ 5 | 6 | # bug #6393 7 | 8 | proc x(): int = 7 9 | proc x(): string = "strange" 10 | -------------------------------------------------------------------------------- /tests/errmsgs/tmultiple_finally.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Only one finally is allowed after all other branches" 3 | """ 4 | 5 | try: 6 | discard 7 | finally: 8 | discard 9 | finally: 10 | discard 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/global/tglobalforvar.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: 100 3 | """ 4 | 5 | var funcs: seq[proc (): int {.nimcall.}] = @[] 6 | for i in 0..10: 7 | funcs.add((proc (): int = return i * i)) 8 | 9 | echo(funcs[3]()) 10 | -------------------------------------------------------------------------------- /tests/lexer/tmissingnl.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | file: "tmissingnl.nim" 4 | line: 7 5 | """ 6 | 7 | import strutils let s: seq[int] = @[0, 1, 2, 3, 4, 5, 6] 8 | 9 | #s[1..3] = @[] 10 | -------------------------------------------------------------------------------- /tests/manyloc/named_argument_bug/tri_engine/math/circle.nim: -------------------------------------------------------------------------------- 1 | import 2 | ../config, 3 | vec 4 | 5 | type 6 | TCircle* = tuple[p: TV2[TR], r: TR] 7 | 8 | converter toCircle*(o: TR): TCircle = 9 | (newV2(), o) 10 | -------------------------------------------------------------------------------- /tests/manyloc/named_argument_bug/tri_engine/math/rect.nim: -------------------------------------------------------------------------------- 1 | import 2 | tri_engine/config, 3 | tri_engine/math/vec 4 | 5 | type 6 | TRect* = tuple[min, size: TV2[TR]] 7 | 8 | proc max*(o: TRect): TV2[TR] = o.min + o.size 9 | -------------------------------------------------------------------------------- /tests/pragmas/t13306.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'testEpo' can have side effects" 3 | line: 8 4 | """ 5 | 6 | import times 7 | 8 | func testEpo(x: float): float = epochTime() + x 9 | 10 | echo testEpo(1.0) 11 | -------------------------------------------------------------------------------- /tests/stdlib/tfenv.nim: -------------------------------------------------------------------------------- 1 | import std/fenv 2 | import std/assertions 3 | 4 | 5 | func is_significant(x: float): bool = 6 | x > minimumPositiveValue(float) and x < maximumPositiveValue(float) 7 | 8 | doAssert is_significant(10.0) 9 | -------------------------------------------------------------------------------- /tests/stdlib/tmemlines.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "" 3 | """ 4 | 5 | import memfiles 6 | var inp = memfiles.open("tests/stdlib/tmemlines.nim") 7 | for line in lines(inp): 8 | echo("#" & line & "#") 9 | close(inp) 10 | -------------------------------------------------------------------------------- /tests/template/tparamscope.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'a'" 3 | line: 10 4 | """ 5 | 6 | 7 | template secondArg(a, b: typed): untyped = 8 | b 9 | 10 | echo secondArg((var a = 1; 1), a) 11 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcaddimmint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var 8 | x = int64.high 9 | discard x + 1 10 | doAssert false 11 | p() 12 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcmulint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var 8 | x = 1'i64 shl 62 9 | discard x * 2 10 | doAssert false 11 | p() 12 | -------------------------------------------------------------------------------- /tests/vm/tvarsection.nim: -------------------------------------------------------------------------------- 1 | var 2 | a {.compileTime.} = 2 3 | b = -1 4 | c {.compileTime.} = 3 5 | d = "abc" 6 | 7 | static: 8 | doAssert a == 2 9 | doAssert c == 3 10 | 11 | doAssert ($b & $d) == "-1abc" 12 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tsortoutput.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | sortoutput: true 3 | output: ''' 4 | 2 5 | 1 6 | ''' 7 | """ 8 | 9 | # this test should ensure that the output is actually sorted 10 | echo "2" 11 | echo "1" 12 | -------------------------------------------------------------------------------- /tests/ambsym/mambsym1.nim: -------------------------------------------------------------------------------- 1 | import mambsym2 # import TExport 2 | 3 | type 4 | TExport* = enum x, y, z 5 | TOtherEnum* = enum mDec, mInc, mAssign 6 | 7 | proc ha() = 8 | var 9 | x: TExport # no error 10 | discard 11 | -------------------------------------------------------------------------------- /tests/array/tidx_lit_err1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "size of array exceeds range of index type 'range 1..2(Color)' by 3 elements" 3 | line: 6 4 | """ 5 | type Color = enum Red, Green, Blue 6 | let y = [Green: 0, 1, 2, 3, 4] 7 | -------------------------------------------------------------------------------- /tests/async/ttemplateinasync.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: 42 3 | """ 4 | 5 | import asyncdispatch 6 | 7 | proc foo(): Future[int] {.async.} = 8 | template ret() = return 42 9 | ret() 10 | 11 | echo (waitFor foo()) 12 | -------------------------------------------------------------------------------- /tests/benchmarks/readme.md: -------------------------------------------------------------------------------- 1 | # Collection of benchmarks 2 | 3 | In future work, benchmarks can be added to CI, but for now we provide benchmarks that can be run locally. 4 | 5 | See RFC: https://github.com/timotheecour/Nim/issues/425 6 | -------------------------------------------------------------------------------- /tests/constructors/t5965_1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "incorrect object construction syntax" 3 | file: "t5965_1.nim" 4 | line: 10 5 | """ 6 | 7 | type Foo = object 8 | a, b, c: int 9 | 10 | discard Foo(a: 1, 2) 11 | -------------------------------------------------------------------------------- /tests/cpp/tgen_prototype_for_importc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | output: '''Hello world''' 4 | """ 5 | 6 | # bug #5136 7 | 8 | {.compile: "foo.c".} 9 | proc myFunc(): cstring {.importc.} 10 | echo myFunc() 11 | -------------------------------------------------------------------------------- /tests/errmsgs/t6281.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'SomeNumber' in this context: 'seq[SomeNumber]' for var" 3 | line: 6 4 | """ 5 | 6 | var seqwat: seq[SomeNumber] = @[] 7 | 8 | proc foo(x: SomeNumber) = 9 | seqwat.add(x) -------------------------------------------------------------------------------- /tests/errmsgs/t9908_01.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "ordinal type expected; given: string" 3 | line: 10 4 | """ 5 | 6 | # https://github.com/nim-lang/Nim/issues/9908 7 | 8 | type 9 | X = enum 10 | a = ("a", "b") 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tgeneral_excepts.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Only one general except clause is allowed after more specific exceptions" 3 | """ 4 | 5 | try: 6 | discard 7 | except: 8 | discard 9 | except: 10 | discard 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tnested_empty_seq.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'empty' in this context: 'array[0..0, (string, seq[empty])]' for var" 3 | line: 8 4 | """ 5 | 6 | # bug #3948 7 | 8 | var headers=[("headers", @[])] 9 | -------------------------------------------------------------------------------- /tests/exception/twrongexc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "Error: unhandled exception: [ValueError]" 3 | exitcode: "1" 4 | """ 5 | try: 6 | raise newException(ValueError, "") 7 | except OverflowDefect: 8 | echo("Error caught") 9 | -------------------------------------------------------------------------------- /tests/js/tcodegendeclvar.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | -1 4 | 2 5 | ''' 6 | ccodecheck: "'console.log(-1); var v_' \\d+ ' = [2]'" 7 | """ 8 | 9 | var v {.codegenDecl: "console.log(-1); var $2".} = 2 10 | echo v 11 | -------------------------------------------------------------------------------- /tests/modules/mmodule_same_proc.nim: -------------------------------------------------------------------------------- 1 | 2 | # the module being the same name as the proc 3 | # is a requirement to trigger the error 4 | import mmodule_same_proc_client 5 | 6 | proc bar*[T](foo: T): bool = foo.mmodule_same_proc_client() 7 | -------------------------------------------------------------------------------- /tests/modules/trecinca.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "recursive dependency: 'trecincb.nim'" 3 | file: "trecincb.nim" 4 | line: 9 5 | """ 6 | # Test recursive includes 7 | 8 | include trecincb 9 | 10 | echo "trecina" 11 | -------------------------------------------------------------------------------- /tests/newconfig/mconfigcheck.nims: -------------------------------------------------------------------------------- 1 | mode = ScriptMode.Verbose 2 | proc build() = 3 | echo "building nim... " 4 | exec "sleep 10" 5 | exec "nonexistant command" 6 | echo getCurrentDir() 7 | 8 | echo "hello" 9 | build() 10 | -------------------------------------------------------------------------------- /tests/overflw/toverflw2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "Error: unhandled exception: over- or underflow [OverflowDefect]" 3 | exitcode: "1" 4 | """ 5 | var a : int32 = 2147483647 6 | var b : int32 = 2147483647 7 | var c = a + b 8 | -------------------------------------------------------------------------------- /tests/parallel/t9691.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--threads:on" 3 | errormsg: "'spawn'ed function cannot have a 'typed' or 'untyped' parameter" 4 | """ 5 | 6 | # bug #9691 7 | 8 | import threadpool 9 | spawn echo() 10 | -------------------------------------------------------------------------------- /tests/parser/ttypecommandindent3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression expected, but found 'keyword do'" 3 | line: 10 4 | column: 1 5 | """ 6 | 7 | type 8 | Foo = call x, y, z: 9 | abc 10 | do: 11 | def 12 | -------------------------------------------------------------------------------- /tests/showoff/thtml1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "
" 3 | """ 4 | 5 | template htmlTag(tag: untyped) = 6 | proc tag(): string = "<" & astToStr(tag) & ">" 7 | 8 | htmlTag(br) 9 | htmlTag(html) 10 | 11 | echo br() 12 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/treject.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "reject" 3 | """ 4 | 5 | # Because we set action="reject", we expect this line not to compile. But the 6 | # line does compile, therefore the test fails. 7 | assert true 8 | -------------------------------------------------------------------------------- /tests/arc/t16033.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c js" 3 | matrix: "--gc:arc" 4 | """ 5 | 6 | # bug #16033 7 | when defined js: 8 | doAssert not compileOption("gc", "arc") 9 | else: 10 | doAssert compileOption("gc", "arc") 11 | -------------------------------------------------------------------------------- /tests/ccgbugs/tborrowmagic.nim: -------------------------------------------------------------------------------- 1 | type 2 | Bytes = distinct seq[byte] 3 | 4 | proc add(x: var Bytes; b: byte) {.borrow.} 5 | var x = @[].Bytes 6 | x.add(42) 7 | let base = cast[seq[byte]](x) 8 | doAssert base.len == 1 and base[0] == 42 9 | -------------------------------------------------------------------------------- /tests/ccgbugs/tweakopenarray.nim: -------------------------------------------------------------------------------- 1 | # bug #4089 2 | 3 | type 4 | Proc = proc(args: openArray[Bar]): Bar 5 | 6 | Foo = object 7 | p: Proc 8 | 9 | Bar = object 10 | f: Foo 11 | 12 | proc bar(val: Foo): Bar = Bar() 13 | -------------------------------------------------------------------------------- /tests/generics/t7446.nim: -------------------------------------------------------------------------------- 1 | proc foo(x: Natural or SomeUnsignedInt):int = 2 | when x is int: 3 | result = 1 4 | else: 5 | result = 2 6 | let a = 10 7 | doAssert foo(a) == 1 8 | 9 | let b = 10'u8 10 | doAssert foo(b) == 2 -------------------------------------------------------------------------------- /tests/misc/åäö.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: run 3 | """ 4 | 5 | # Tests that module names can contain multi byte characters 6 | 7 | let a = 1 8 | doAssert åäö.a == 1 9 | 10 | proc inlined() {.inline.} = discard 11 | inlined() -------------------------------------------------------------------------------- /tests/modules/trecincb.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "recursive dependency: 'trecincb.nim'" 3 | file: "trecincb.nim" 4 | line: 9 5 | """ 6 | # Test recursive includes 7 | 8 | 9 | include trecincb 10 | 11 | echo "trecinb" 12 | -------------------------------------------------------------------------------- /tests/overload/tissue966.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | """ 4 | 5 | type 6 | PTest = ref object 7 | 8 | proc test(x: PTest, y: int) = discard 9 | 10 | var buf: PTest 11 | buf.test() 12 | 13 | -------------------------------------------------------------------------------- /tests/parallel/tsysspawnbadarg.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'spawn' takes a call expression" 3 | line: 9 4 | cmd: "nim $target --threads:on $options $file" 5 | """ 6 | 7 | import threadpool 8 | 9 | let foo = spawn(1) 10 | -------------------------------------------------------------------------------- /tests/pragmas/tcompile_pragma.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''34''' 3 | joinable: false 4 | """ 5 | 6 | {.compile("cfunction.c", "-DNUMBER_HERE=34").} 7 | 8 | proc cfunction(): cint {.importc.} 9 | 10 | echo cfunction() 11 | -------------------------------------------------------------------------------- /tests/stdlib/mjsonexternproc.nim: -------------------------------------------------------------------------------- 1 | # Test case for https://github.com/nim-lang/Nim/issues/6385 2 | 3 | import json 4 | # export json 5 | 6 | proc foo*[T](a: T) = 7 | let params = %*{ 8 | "data": [ 1 ] 9 | } 10 | echo $params -------------------------------------------------------------------------------- /tests/stdlib/nre/escape.nim: -------------------------------------------------------------------------------- 1 | import nre, unittest 2 | 3 | block: # escape strings 4 | block: # escape strings 5 | check("123".escapeRe() == "123") 6 | check("[]".escapeRe() == r"\[\]") 7 | check("()".escapeRe() == r"\(\)") 8 | -------------------------------------------------------------------------------- /tests/stdlib/tjsonexternproc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | {"data":[1]} 4 | ''' 5 | """ 6 | 7 | # Test case for https://github.com/nim-lang/Nim/issues/6385 8 | 9 | import mjsonexternproc 10 | # import json 11 | foo(1) 12 | -------------------------------------------------------------------------------- /tests/stdlib/tlocks.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp js" 3 | matrix: "--threads:on" 4 | """ 5 | 6 | #bug #6049 7 | import uselocks 8 | import std/assertions 9 | 10 | var m = createMyType[int]() 11 | doAssert m.use() == 3 12 | -------------------------------------------------------------------------------- /tests/stmt/tforloop_tuple_multiple_underscore.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: '_'" 3 | """ 4 | 5 | iterator iter(): (int, int, int) = 6 | yield (1, 1, 2) 7 | 8 | 9 | for (_, i, _) in iter(): 10 | echo _ -------------------------------------------------------------------------------- /tests/template/template_pragmas.nim: -------------------------------------------------------------------------------- 1 | proc output_x:string {.compileTime.} = "x" 2 | 3 | template t = 4 | const x = output_x() 5 | let 6 | bar {.exportc:"bar" & x.} = 100 7 | 8 | static: 9 | doAssert(compiles (t())) 10 | -------------------------------------------------------------------------------- /tests/types/tillegaltyperecursion3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'Weird'" 3 | """ 4 | 5 | # issue #3456 6 | 7 | import tables 8 | type 9 | Weird = ref seq[Weird] 10 | var t = newTable[int, Weird]() 11 | -------------------------------------------------------------------------------- /tests/varres/tvarres3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "45" 3 | """ 4 | 5 | var 6 | g = 5 7 | 8 | proc p(): var int = 9 | var bla = addr(g) #: array[0..7, int] 10 | result = bla[] 11 | 12 | p() = 45 13 | 14 | echo g 15 | 16 | -------------------------------------------------------------------------------- /tests/arc/t16558.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--gc:arc" 3 | errormsg: "expression cannot be cast to 'int'" 4 | """ 5 | 6 | block: # bug #16558 7 | var value = "hi there" 8 | var keepInt: int 9 | keepInt = cast[int](value) 10 | -------------------------------------------------------------------------------- /tests/ccgbugs/t9098.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp js" 3 | output: ''' 4 | {'a', 'b'} 5 | ''' 6 | """ 7 | 8 | var x = new(ref set[char]) 9 | var y = new(ref set[char]) 10 | x[] = {'a'} 11 | y[] = {'b'} 12 | echo x[] + y[] 13 | -------------------------------------------------------------------------------- /tests/compiles/t8630.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | foo 4 | bar 5 | ''' 6 | """ 7 | 8 | proc test(strings: seq[string]) = 9 | for s in strings: 10 | var p3 = addr(s) 11 | echo p3[] 12 | 13 | test(@["foo", "bar"]) 14 | -------------------------------------------------------------------------------- /tests/converter/tconverter.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''fooo fooo''' 3 | """ 4 | 5 | converter intToString[T](i: T): string = "fooo" 6 | 7 | let 8 | foo: string = 1 9 | bar: string = intToString(2) 10 | 11 | echo foo, " ", bar -------------------------------------------------------------------------------- /tests/cpp/tenum_set.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | output: "{A, B, C}" 4 | """ 5 | 6 | type Enum {.importcpp: "namespaced::Enum", header: "enum.hpp".} = enum A, B, C 7 | 8 | var vals = {low(Enum) .. high(Enum)} 9 | echo vals 10 | -------------------------------------------------------------------------------- /tests/destructor/tgotoexceptions3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc --exceptions:goto $file" 3 | outputsub: "Error: unhandled exception: Problem [OSError]" 4 | exitcode: "1" 5 | """ 6 | 7 | raise newException(OSError, "Problem") 8 | -------------------------------------------------------------------------------- /tests/effects/teffects10.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | # https://github.com/nim-lang/Nim/issues/15495 6 | 7 | proc f() {.raises: [].} = 8 | var a: proc () 9 | var b: proc () 10 | swap(a, b) 11 | 12 | f() 13 | -------------------------------------------------------------------------------- /tests/friends/tfriends.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "3" 3 | """ 4 | 5 | # Tests that a generic instantiation from a different module may access 6 | # private object fields: 7 | 8 | import mfriends 9 | 10 | echo gen[int]() 11 | 12 | -------------------------------------------------------------------------------- /tests/ic/mimports.nim: -------------------------------------------------------------------------------- 1 | from mimportsb {.all.} import fnb1, hfnb3 2 | 3 | proc fn1*(): int = 1 4 | proc fn2*(): int = 2 5 | proc hfn3(): int = 3 6 | proc hfn4(): int = 4 7 | proc hfn5(): int = 5 8 | 9 | export mimportsb.fnb2, hfnb3 10 | -------------------------------------------------------------------------------- /tests/importalls/mt0.nim: -------------------------------------------------------------------------------- 1 | import ./m1 as m 2 | doAssert compiles(foo0) 3 | doAssert not compiles(foo1) 4 | doAssert foo6b() == 2 5 | doAssert m3h2 == 2 6 | 7 | var f = initFoo5(z3=3) 8 | doAssert f.z3 == 30 9 | doAssert z3(f) == 30 10 | -------------------------------------------------------------------------------- /tests/js/testmagic.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''true 3 | 123 4 | ''' 5 | """ 6 | 7 | # This file tests some magic 8 | 9 | var foo = cstring("foo") 10 | var bar = cstring("foo") 11 | echo(foo == bar) 12 | echo "01234"[1 .. ^2] 13 | -------------------------------------------------------------------------------- /tests/macros/treturnsempty.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | line: 11 4 | """ 5 | # bug #2372 6 | macro foo(dummy: int): untyped = 7 | discard 8 | 9 | proc takeStr(s: string) = echo s 10 | 11 | takeStr foo(12) 12 | -------------------------------------------------------------------------------- /tests/tuples/twrongtupleaccess.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "attempting to call undeclared routine: \'setBLAH\'" 3 | file: "twrongtupleaccess.nim" 4 | line: 9 5 | """ 6 | # Bugfix 7 | 8 | var v = (5.0, 10.0) 9 | v.setBLAH(10) 10 | -------------------------------------------------------------------------------- /tests/typerel/ttypedesc_as_genericparam2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc" 3 | errormsg: "'repr' doesn't support 'void' type" 4 | line: 10 5 | """ 6 | 7 | # bug #2879 8 | 9 | var s: seq[int] 10 | echo repr(s.new_seq(3)) 11 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcaddint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var 8 | x = int64.high 9 | y = 1 10 | discard x + y 11 | doAssert false 12 | p() 13 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcsubint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var 8 | x = int64.low 9 | y = 1 10 | discard x - y 11 | doAssert false 12 | p() 13 | -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/minclude_include.nim: -------------------------------------------------------------------------------- 1 | # this file is included and relies on imports within the include 2 | 3 | proc create*(greeting: string = "Hello", subject: string = "World"): Greet = 4 | Greet(greeting: greeting, subject: subject) 5 | -------------------------------------------------------------------------------- /tests/async/tasync_nofuture.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "await expects Future[T], got int" 3 | cmd: "nim c $file" 4 | file: "asyncmacro.nim" 5 | """ 6 | import async 7 | 8 | proc a {.async.} = 9 | await 0 10 | 11 | waitFor a() 12 | -------------------------------------------------------------------------------- /tests/bind/tinvalidbindtypedesc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | line: 10 4 | """ 5 | 6 | proc foo(T: typedesc; some: T) = 7 | echo($some) 8 | 9 | foo int, 4 10 | foo float, "bad" 11 | -------------------------------------------------------------------------------- /tests/errmsgs/t9908_02.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "ordinal type expected; given: float" 3 | line: 10 4 | """ 5 | 6 | # https://github.com/nim-lang/Nim/pull/9909#issuecomment-445519287 7 | 8 | type 9 | E = enum 10 | myVal = 80.9 11 | -------------------------------------------------------------------------------- /tests/gensym/tgensym.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "123100" 3 | """ 4 | 5 | template hygienic(val) = 6 | var x = val 7 | stdout.write x 8 | 9 | var x = 100 10 | 11 | hygienic 1 12 | hygienic 2 13 | hygienic 3 14 | 15 | echo x 16 | 17 | -------------------------------------------------------------------------------- /tests/macros/tisexported.nim: -------------------------------------------------------------------------------- 1 | import macros 2 | 3 | proc t1* = discard 4 | proc t2 = discard 5 | 6 | macro check(p1: typed, p2: typed) = 7 | doAssert isExported(p1) == true 8 | doAssert isExported(p2) == false 9 | 10 | check t1, t2 11 | -------------------------------------------------------------------------------- /tests/method/mmultim3.nim: -------------------------------------------------------------------------------- 1 | type 2 | TObj* {.inheritable.} = object 3 | 4 | var myObj* : ref TObj 5 | 6 | method test123(a : ref TObj) {.base.} = 7 | echo("Hi base!") 8 | 9 | proc testMyObj*() = 10 | test123(myObj) 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/misc/tnoop.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: ''' 3 | found 'a' [var declared in tnoop.nim(10, 3)] 4 | ''' 5 | file: "tnoop.nim" 6 | errormsg: "attempting to call routine: 'a'" 7 | """ 8 | 9 | var 10 | a: int 11 | 12 | a() 13 | -------------------------------------------------------------------------------- /tests/misc/trawstr.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "closing \" expected" 3 | file: "trawstr.nim" 4 | line: 10 5 | """ 6 | # Test the new raw strings: 7 | 8 | const 9 | xxx = r"This is a raw string!" 10 | yyy = "This not\" #ERROR 11 | -------------------------------------------------------------------------------- /tests/misc/tsimtych.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected \'string\'" 3 | file: "tsimtych.nim" 4 | line: 10 5 | """ 6 | # Test 2 7 | # Simple type checking 8 | 9 | var a: string 10 | a = false #ERROR 11 | -------------------------------------------------------------------------------- /tests/pragmas/custom_pragma.nim: -------------------------------------------------------------------------------- 1 | # imported by tcustom_pragmas to test scoping 2 | 3 | template serializationKey*(s: string) {.pragma.} 4 | template defaultValue*(V: typed) {.pragma.} 5 | template alternativeKey*(s: string = "", V: typed) {.pragma.} 6 | -------------------------------------------------------------------------------- /tests/sets/m17385.nim: -------------------------------------------------------------------------------- 1 | import std/sets 2 | 3 | type 4 | Diff*[T] = object 5 | data: T 6 | 7 | proc test*[T](diff: Diff[T]) = 8 | var bPopular = initHashSet[T]() 9 | for element in bPopular.items(): 10 | echo element 11 | 12 | -------------------------------------------------------------------------------- /tests/showoff/thello2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''(a: 3, b: 4, s: "abc")''' 3 | """ 4 | 5 | type 6 | MyObject = object 7 | a, b: int 8 | s: string 9 | 10 | let obj = MyObject(a: 3, b: 4, s: "abc") 11 | echo obj 12 | -------------------------------------------------------------------------------- /tests/stdlib/tssl.nims: -------------------------------------------------------------------------------- 1 | --threads:on 2 | --d:ssl 3 | when defined(freebsd) or defined(netbsd): 4 | # See https://github.com/nim-lang/Nim/pull/15066#issuecomment-665541265 and https://github.com/nim-lang/Nim/issues/15493 5 | --tlsEmulation:off 6 | -------------------------------------------------------------------------------- /tests/stdlib/tterminal_12759.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | """ 4 | 5 | import terminal 6 | import std/syncio 7 | 8 | proc test() {.raises:[IOError, ValueError].} = 9 | setBackgroundColor(stdout, bgRed) 10 | 11 | test() 12 | -------------------------------------------------------------------------------- /tests/varstmt/tvardecl.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "44" 3 | """ 4 | # Test the new variable declaration syntax 5 | 6 | var 7 | x = 0 8 | s = "Hallo" 9 | a, b: int = 4 10 | 11 | write(stdout, a) 12 | writeLine(stdout, b) #OUT 44 13 | -------------------------------------------------------------------------------- /tools/atlas/tests/sync.nimble: -------------------------------------------------------------------------------- 1 | # Package 2 | 3 | version = "1.4.0" 4 | author = "Antonis Geralis" 5 | description = "Useful synchronization primitives." 6 | license = "MIT" 7 | 8 | # Deps 9 | 10 | requires "nim >= 1.0.0" 11 | -------------------------------------------------------------------------------- /nimsuggest/tests/top_highlight.nim: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | %*{}#[!]# 4 | 5 | discard """ 6 | $nimsuggest --tester $file 7 | >highlight $1 8 | highlight;;skModule;;1;;7;;4 9 | highlight;;skMacro;;3;;0;;2 10 | highlight;;skMacro;;3;;0;;2 11 | """ 12 | -------------------------------------------------------------------------------- /nimsuggest/tests/ttemplate_highlight.nim: -------------------------------------------------------------------------------- 1 | doAssert true#[!]# 2 | 3 | discard """ 4 | $nimsuggest --tester $1 5 | >highlight $1 6 | highlight;;skTemplate;;1;;0;;8 7 | highlight;;skTemplate;;1;;0;;8 8 | highlight;;skEnumField;;1;;9;;4 9 | """ 10 | -------------------------------------------------------------------------------- /tests/async/t7192.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | testCallback() 4 | ''' 5 | """ 6 | 7 | import asyncdispatch 8 | 9 | proc testCallback() = 10 | echo "testCallback()" 11 | 12 | when true: 13 | callSoon(testCallback) 14 | poll() 15 | -------------------------------------------------------------------------------- /tests/errmsgs/tstaticexprscope.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'z'" 3 | line: 11 4 | """ 5 | 6 | # Open a new scope for static expr blocks 7 | block: 8 | let a = static: 9 | var z = 123 10 | 33 11 | echo z 12 | -------------------------------------------------------------------------------- /tests/errmsgs/tstaticresult.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: ''' 3 | invalid type: 'static[int]' in this context: 'proc (x: int): static[int]' for proc 4 | ''' 5 | """ 6 | 7 | proc foo(x: int): static int = 8 | x + 123 9 | 10 | echo foo(123) 11 | -------------------------------------------------------------------------------- /tests/errmsgs/twrongcolon.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "in expression ' do:" 3 | nimout: ''' 4 | twrongcolon.nim(10, 12) Error: in expression ' do: 5 | 890': identifier expected, but found '' 6 | ''' 7 | 8 | """ 9 | 10 | var n: int : 890 11 | -------------------------------------------------------------------------------- /tests/js/tconsole.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | Hello, console 4 | 1 2 3 5 | ''' 6 | """ 7 | 8 | # This file tests the JavaScript console 9 | 10 | import jsconsole 11 | 12 | console.log("Hello, console") 13 | console.log(1, 2, 3) 14 | -------------------------------------------------------------------------------- /tests/misc/tnoforward.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "10" 3 | """ 4 | 5 | # {. noforward: on .} 6 | {.experimental: "codeReordering".} 7 | 8 | proc foo(x: int) = 9 | bar x 10 | 11 | proc bar(x: int) = 12 | echo x 13 | 14 | foo(10) 15 | 16 | -------------------------------------------------------------------------------- /tests/modules/mrecmod2.nim: -------------------------------------------------------------------------------- 1 | # Module B 2 | import trecmod2 3 | 4 | proc p*(x: trecmod2.T1): trecmod2.T1 = 5 | # this works because the compiler has already 6 | # added T1 to trecmod2's interface symbol table 7 | return x + 1 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/modules/texport2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | abc 4 | xyz 5 | B.foo 6 | ''' 7 | """ 8 | 9 | # bug #1595, #1612 10 | 11 | import mexport2a 12 | 13 | proc main() = 14 | printAbc() 15 | printXyz() 16 | 17 | main() 18 | foo(3) 19 | -------------------------------------------------------------------------------- /tests/modules/tnamspc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: \'global\'" 3 | file: "tnamspc.nim" 4 | line: 10 5 | """ 6 | # Test17 - test correct handling of namespaces 7 | 8 | import mnamspc1 9 | 10 | global = 9 #ERROR 11 | -------------------------------------------------------------------------------- /tests/pragmas/t12558.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: '''@["1", "2", "3"]''' 3 | """ 4 | 5 | import sequtils 6 | 7 | {.push compile_time.} 8 | 9 | proc foo = 10 | echo map_it([1, 2, 3], $it) 11 | 12 | {.pop.} 13 | 14 | static: 15 | foo() 16 | -------------------------------------------------------------------------------- /tests/pragmas/t5149.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "{.exportc.} not allowed for type aliases" 3 | line: 9 4 | """ 5 | 6 | type 7 | X* = object 8 | a: int 9 | Y* {.exportc.} = X 10 | 11 | proc impl*(x: X) = 12 | echo "it works" 13 | -------------------------------------------------------------------------------- /tests/pragmas/tpush.nim: -------------------------------------------------------------------------------- 1 | # test the new pragmas 2 | 3 | {.push warnings: off, hints: off.} 4 | proc noWarning() = 5 | var 6 | x: int 7 | echo(x) 8 | 9 | {.pop.} 10 | 11 | proc WarnMe() = 12 | var 13 | x: int 14 | echo(x) 15 | 16 | -------------------------------------------------------------------------------- /tests/stdlib/concurrency/atomicSample.nim: -------------------------------------------------------------------------------- 1 | import atomics 2 | 3 | type 4 | AtomicWithGeneric*[T] = object 5 | value: Atomic[T] 6 | 7 | proc initAtomicWithGeneric*[T](value: T): AtomicWithGeneric[T] = 8 | result.value.store(value) 9 | 10 | -------------------------------------------------------------------------------- /tests/stdlib/t14139.nim: -------------------------------------------------------------------------------- 1 | import std/heapqueue 2 | import std/assertions 3 | 4 | var test_queue : HeapQueue[int] 5 | 6 | test_queue.push(7) 7 | test_queue.push(3) 8 | test_queue.push(9) 9 | let i = test_queue.pushpop(10) 10 | doAssert i == 3 11 | -------------------------------------------------------------------------------- /tests/template/tredefinition.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "redefinition of 'a`gensym" 3 | line: 9 4 | """ 5 | # bug #10180 6 | proc f() = 7 | template t() = 8 | var a = 1 9 | var a = 2 10 | echo a 11 | t() 12 | 13 | f() 14 | -------------------------------------------------------------------------------- /tests/template/twhenintemplates.nim: -------------------------------------------------------------------------------- 1 | # bug #3670 2 | 3 | template someTempl(someConst: bool) = 4 | when someConst: 5 | var a : int 6 | if true: 7 | when not someConst: 8 | var a : int 9 | a = 5 10 | 11 | someTempl(true) 12 | -------------------------------------------------------------------------------- /tests/typerel/tclosure_nil_as_default.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #4328 3 | type 4 | foo[T] = object 5 | z: T 6 | 7 | proc test[T](x: foo[T], p: proc(a: T) = nil) = 8 | discard 9 | 10 | var d: foo[int] 11 | d.test() # <- param omitted 12 | -------------------------------------------------------------------------------- /tests/types/tillegalrecursion3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'Foo'" 3 | """ 4 | 5 | type 6 | Imported {.importc.} = object 7 | 8 | Foo = object 9 | b: Imported 10 | a: Foo 11 | 12 | var myFoo: Foo 13 | -------------------------------------------------------------------------------- /tests/varres/tvarres2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression has no address" 3 | file: "tvarres2.nim" 4 | line: 11 5 | """ 6 | 7 | var 8 | g = 5 9 | 10 | proc p(): var int = 11 | result = 89 12 | 13 | p() = 45 14 | 15 | echo g 16 | -------------------------------------------------------------------------------- /tests/varres/tvartup.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "2 3" 3 | """ 4 | # Test the new tuple unpacking 5 | 6 | proc divmod(a, b: int): tuple[di, mo: int] = 7 | return (a div b, a mod b) 8 | 9 | var (x, y) = divmod(15, 6) 10 | echo x, " ", y 11 | -------------------------------------------------------------------------------- /nimsuggest/tests/tchk_compiles.nim: -------------------------------------------------------------------------------- 1 | discard compiles(2 + "hello") 2 | 3 | #[!]# 4 | discard """ 5 | $nimsuggest --tester $file 6 | >chk $1 7 | chk;;skUnknown;;;;Hint;;???;;0;;-1;;">> (toplevel): import(dirty): tests/tchk_compiles.nim [Processing]";;0 8 | """ 9 | -------------------------------------------------------------------------------- /tests/cpp/tterminate_handler.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | outputsub: "Error: unhandled unknown cpp exception" 4 | exitcode: 1 5 | disabled: true 6 | """ 7 | type Crap {.importcpp: "int".} = object 8 | 9 | var c: Crap 10 | raise c 11 | -------------------------------------------------------------------------------- /tests/js/ttryexceptnewsyntax.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''hello''' 3 | """ 4 | 5 | type 6 | MyException = ref Exception 7 | 8 | #bug #5986 9 | 10 | try: 11 | raise MyException(msg: "hello") 12 | except MyException as e: 13 | echo e.msg 14 | -------------------------------------------------------------------------------- /tests/misc/tdangerisrelease.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c $options -r $file" 3 | matrix: "-d:danger; -d:release" 4 | output: ''' 5 | a 6 | b 7 | c 8 | ''' 9 | """ 10 | 11 | echo "a" 12 | when defined(release): 13 | echo "b" 14 | echo "c" 15 | -------------------------------------------------------------------------------- /tests/nimble/tnimblepathdollar.nims: -------------------------------------------------------------------------------- 1 | switch("clearNimblePath") 2 | switch("nimblePath", "$projectdir/nimbleDir/simplePkgs") 3 | switch("path", "$nimblepath/pkgA-0.1.0") 4 | switch("path", "$nimblepath/pkgB-#head") 5 | switch("path", "$nimblepath/pkgC-#head") 6 | -------------------------------------------------------------------------------- /tests/rational/trat_float.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: '''type mismatch: got''' 3 | file: "trat_float.nim" 4 | line: "9,19" 5 | """ 6 | import rationals 7 | var 8 | # this fails - no floats as num or den 9 | r = initRational(1.0'f, 1.0'f) 10 | -------------------------------------------------------------------------------- /tests/stdlib/mintsets.nim: -------------------------------------------------------------------------------- 1 | import std/intsets 2 | import std/assertions 3 | 4 | proc test1*[]() = 5 | let a = initIntSet() 6 | doAssert len(a) == 0 7 | 8 | proc test2*[]() = 9 | var a = initIntSet() 10 | var b = initIntSet() 11 | a.incl b 12 | -------------------------------------------------------------------------------- /tests/types/tauto_canbe_void.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | arg 4 | arg 5 | ''' 6 | """ 7 | 8 | 9 | import sugar 10 | 11 | template tempo(s) = 12 | s("arg") 13 | 14 | tempo((s: string)->auto => echo(s)) 15 | tempo((s: string) => echo(s)) 16 | -------------------------------------------------------------------------------- /tests/types/tfinalobj.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''abc''' 3 | """ 4 | 5 | type 6 | TA {.pure, final.} = object 7 | x: string 8 | 9 | var 10 | a: TA 11 | a.x = "abc" 12 | 13 | doAssert TA.sizeof == string.sizeof 14 | 15 | echo a.x 16 | -------------------------------------------------------------------------------- /tests/varres/tnewseq_on_result_vart.nim: -------------------------------------------------------------------------------- 1 | 2 | discard """ 3 | errormsg: "address of 'result' may not escape its stack frame" 4 | line: 9 5 | """ 6 | # bug #5113 7 | 8 | proc makeSeqVar(size: Natural): var seq[int] = 9 | newSeq(result, size) 10 | -------------------------------------------------------------------------------- /tests/vm/twrongwhen.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot evaluate at compile time: x" 3 | line: 7 4 | """ 5 | 6 | proc bla(x:int) = 7 | when x == 0: 8 | echo "oops" 9 | else: 10 | echo "good" 11 | 12 | bla(2) # echos "oops" 13 | 14 | -------------------------------------------------------------------------------- /nimsuggest/nimsuggest.nimble: -------------------------------------------------------------------------------- 1 | version = "0.1.0" 2 | author = "Andreas Rumpf" 3 | description = "Tool for providing auto completion data for Nim source code." 4 | license = "MIT" 5 | 6 | bin = @["nimsuggest"] 7 | 8 | requires "nim >= 1.1.1" 9 | -------------------------------------------------------------------------------- /nimsuggest/tests/tobj_highlight.nim: -------------------------------------------------------------------------------- 1 | type 2 | O = object 3 | a*: int#[!]# 4 | 5 | discard """ 6 | $nimsuggest --tester $file 7 | >highlight $1 8 | highlight;;skType;;2;;2;;1 9 | highlight;;skType;;3;;8;;3 10 | highlight;;skField;;3;;4;;1 11 | """ 12 | -------------------------------------------------------------------------------- /testament/testament.nim.cfg: -------------------------------------------------------------------------------- 1 | # don't move this file without updating the logic in `isNimRepoTests` 2 | 3 | path = "$nim" # For compiler/nodejs 4 | -d:ssl # For azure 5 | # my SSL doesn't have this feature and I don't care: 6 | -d:nimDisableCertificateValidation 7 | -------------------------------------------------------------------------------- /tests/async/tnestedpfuturetypeparam.nim: -------------------------------------------------------------------------------- 1 | import asyncdispatch, asyncnet 2 | 3 | proc main {.async.} = 4 | proc f: Future[seq[int]] {.async.} = 5 | await newAsyncSocket().connect("www.google.com", Port(80)) 6 | let x = await f() 7 | 8 | asyncCheck main() 9 | -------------------------------------------------------------------------------- /tests/casestmt/tcaseoverlaprange.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "duplicate case label" 3 | line: 13 4 | """ 5 | 6 | type 7 | TE = enum A, B, C, D 8 | 9 | var 10 | e: TE 11 | 12 | case e 13 | of A..D, B..C: 14 | echo "redundant" 15 | else: nil 16 | -------------------------------------------------------------------------------- /tests/ccgbugs/tarray_equality.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''true 3 | true''' 4 | """ 5 | 6 | # bug #2489 7 | 8 | let a = [1] 9 | let b = [1] 10 | echo a == b 11 | 12 | # bug #2498 13 | var x: array[0, int] 14 | var y: array[0, int] 15 | echo x == y 16 | -------------------------------------------------------------------------------- /tests/ccgbugs/tcapture_static.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''hi''' 3 | """ 4 | 5 | # bug #4551 6 | 7 | proc foo() = 8 | let arr = ["hi"] 9 | for i, v in arr: 10 | let bar = proc = 11 | echo v 12 | bar() 13 | foo() 14 | -------------------------------------------------------------------------------- /tests/closure/tinvalidclosure3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal capture 'x'" 3 | line: 9 4 | """ 5 | 6 | proc outer(arg: string) = 7 | var x = 0 8 | proc inner {.inline.} = 9 | echo "inner", x 10 | inner() 11 | 12 | outer("abc") 13 | -------------------------------------------------------------------------------- /tests/generics/mclosed_sym.nim: -------------------------------------------------------------------------------- 1 | 2 | type R* = object 3 | 4 | type Data*[T] = object 5 | d*: T 6 | 7 | proc same(r:R, d:int) = echo "TEST2" 8 | 9 | proc doIt*(d:Data, r:R) = 10 | r.same(1) # Expecting this to invoke the local `same()` method 11 | -------------------------------------------------------------------------------- /tests/ic/tstdlib_import_changed.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''yes''' 3 | """ 4 | 5 | echo "yes" 6 | 7 | #!EDIT!# 8 | 9 | discard """ 10 | output: '''yes2''' 11 | """ 12 | 13 | import std / [monotimes] 14 | #discard getMonoTime() 15 | echo "yes2" 16 | -------------------------------------------------------------------------------- /tests/importalls/tmain2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false # for clarity, but not necessary 3 | """ 4 | 5 | {.warning[UnusedImport]: off.} 6 | # only import `mt*.nim` here; these depend on `m*.nim` 7 | import "."/[mt0,mt1,mt2,mt3,mt4,mt4b,mt5,mt6,mt7,mt8,mt9] 8 | -------------------------------------------------------------------------------- /tests/manyloc/keineschweine/enet_server/server_settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Alpha Zone", 3 | "desc": "Beta Testing", 4 | "host": "localhost", 5 | "port": 8024, 6 | "settings": "alphazone.json", 7 | "dirserver":["localhost",2049,"alphazone","skittles"] 8 | } 9 | -------------------------------------------------------------------------------- /tests/misc/tinvalidarrayaccess2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "index 3 not in 0 .. 1" 3 | line: 9 4 | """ 5 | 6 | # Note: merge in tinvalidarrayaccess.nim pending https://github.com/nim-lang/Nim/issues/9906 7 | 8 | let a = [1,2] 9 | echo a[3] 10 | 11 | -------------------------------------------------------------------------------- /tests/misc/tissue710.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errorMsg: "attempting to call routine: '||'" 3 | file: "tissue710.nim" 4 | line: 8 5 | """ 6 | var sum = 0 7 | for x in 3..1000: 8 | if (x mod 3 == 0) || (x mod 5 == 0): 9 | sum += x 10 | echo(sum) 11 | -------------------------------------------------------------------------------- /tests/modules/tnotuniquename2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "module names need to be unique per Nimble package" 3 | file: "tnotuniquename/mnotuniquename.nim" 4 | disabled: "true" 5 | """ 6 | 7 | import mnotuniquename 8 | import tnotuniquename/mnotuniquename 9 | -------------------------------------------------------------------------------- /tests/modules/tselfimport.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "module 'tselfimport' cannot import itself" 3 | file: "tselfimport.nim" 4 | line: 7 5 | """ 6 | import strutils as su # guard against regression 7 | import tselfimport #ERROR 8 | echo("Hello World") 9 | -------------------------------------------------------------------------------- /tests/nimble/tnimblepathdollar_fault.nims: -------------------------------------------------------------------------------- 1 | switch("noNimblePath") 2 | switch("nimblePath", "$projectdir/nimbleDir/simplePkgs") 3 | switch("path", "$nimblepath/pkgA-0.1.0") 4 | switch("path", "$nimblepath/pkgB-#head") 5 | switch("path", "$nimblepath/pkgC-#head") 6 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter7/Tweeter/src/createDatabase.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "Database created successfully!" 3 | """ 4 | 5 | import database 6 | 7 | var db = newDatabase() 8 | db.setup() 9 | echo("Database created successfully!") 10 | db.close() 11 | -------------------------------------------------------------------------------- /tests/overload/tnamedparamoverloading.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | Using x: 2 4 | Using y: 2 5 | ''' 6 | """ 7 | 8 | proc foo(x: int) = 9 | echo "Using x: ", x 10 | proc foo(y: int) = 11 | echo "Using y: ", y 12 | 13 | foo(x = 2) 14 | foo(y = 2) -------------------------------------------------------------------------------- /tests/async/tgenericasync.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''123 3 | abc''' 4 | """ 5 | 6 | # bug #4856 7 | 8 | import asyncdispatch 9 | 10 | proc say[T](t: T): Future[void] {.async.} = 11 | echo $t 12 | 13 | waitFor(say(123)) 14 | waitFor(say("abc")) 15 | -------------------------------------------------------------------------------- /tests/iter/twrongiter.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | line: 12 4 | """ 5 | 6 | proc first(it: iterator(): int): seq[int] = 7 | return @[] 8 | 9 | iterator primes(): int = 10 | yield 1 11 | 12 | for i in first(primes): 13 | break 14 | -------------------------------------------------------------------------------- /tests/js/t12303.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "{ b: 2 }" 3 | """ 4 | 5 | import jsconsole, jsffi 6 | 7 | type 8 | A = ref object 9 | b: B 10 | 11 | B = object 12 | b: int 13 | 14 | var a = cast[A](js{}) 15 | a.b = B(b: 2) 16 | console.log a.b 17 | -------------------------------------------------------------------------------- /tests/lexer/tintegerliterals.nim: -------------------------------------------------------------------------------- 1 | # test the valid literals 2 | doAssert 0b10 == 2 3 | doAssert 0B10 == 2 4 | doAssert 0x10 == 16 5 | doAssert 0X10 == 16 6 | doAssert 0o10 == 8 7 | # the following is deprecated: 8 | doAssert 0c10 == 8 9 | doAssert 0C10 == 8 10 | -------------------------------------------------------------------------------- /tests/notnil/tnotnil.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | line: 13 4 | """ 5 | {.experimental: "notnil".} 6 | type 7 | PObj = ref TObj not nil 8 | TObj = object 9 | x: int 10 | 11 | proc q2(x: string) = discard 12 | 13 | q2(nil) 14 | -------------------------------------------------------------------------------- /tests/pragmas/mused3b.nim: -------------------------------------------------------------------------------- 1 | when defined case1: 2 | proc gn1*()=discard 3 | 4 | when defined case8: 5 | proc gn1*()=discard 6 | 7 | when defined case9: 8 | proc gn1*()=discard 9 | 10 | when defined case10: 11 | type Foo* = object 12 | f0*: int 13 | -------------------------------------------------------------------------------- /tests/views/tmust_borrow_from_first_parameter.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'result' must borrow from the first parameter" 3 | line: 9 4 | """ 5 | 6 | {.experimental: "views".} 7 | 8 | proc p(a, b: openArray[char]): openArray[char] = 9 | result = b 10 | -------------------------------------------------------------------------------- /lib/std/vmutils.nim: -------------------------------------------------------------------------------- 1 | ##[ 2 | Experimental API, subject to change. 3 | ]## 4 | 5 | proc vmTrace*(on: bool) {.compileTime.} = 6 | runnableExamples: 7 | static: vmTrace(true) 8 | proc fn = 9 | var a = 1 10 | vmTrace(false) 11 | static: fn() 12 | -------------------------------------------------------------------------------- /nimsuggest/tests/tsetter_highlight.nim: -------------------------------------------------------------------------------- 1 | proc `a=`(a, b: int) = discard 2 | 10.a = 1000#[!]# 3 | 4 | discard """ 5 | $nimsuggest --tester $file 6 | >highlight $1 7 | highlight;;skProc;;1;;6;;2 8 | highlight;;skType;;1;;16;;3 9 | highlight;;skProc;;2;;5;;1 10 | """ 11 | -------------------------------------------------------------------------------- /tests/async/tdiscardableproc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Cannot make async proc discardable. Futures have to be checked with `asyncCheck` instead of discarded" 3 | """ 4 | 5 | import async 6 | 7 | proc foo {.async, discardable.} = discard 8 | 9 | foo() 10 | -------------------------------------------------------------------------------- /tests/closure/tinvalidclosure2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal capture 'A'" 3 | line: 10 4 | """ 5 | 6 | proc outer() = 7 | var A: int 8 | 9 | proc ugh[T](x: T) {.cdecl.} = 10 | echo "ugha", A, x 11 | 12 | ugh[int](12) 13 | 14 | outer() 15 | -------------------------------------------------------------------------------- /tests/errmsgs/t1154.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'untyped' in this context: 'proc (a: varargs[untyped])' for proc" 3 | line: 8 4 | """ 5 | 6 | import typetraits 7 | 8 | proc foo(a:varargs[untyped]) = 9 | echo a[0].type.name 10 | 11 | foo(1) 12 | -------------------------------------------------------------------------------- /tests/gc/tstandalone.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--os:standalone --gc:none" 3 | exitcode: 1 4 | output: "value out of range" 5 | """ 6 | 7 | type 8 | rangeType = range[0..1] 9 | 10 | var 11 | r: rangeType = 0 12 | i = 2 13 | 14 | r = rangeType(i) 15 | -------------------------------------------------------------------------------- /tests/generics/t2tables.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | # bug #3669 6 | 7 | import tables 8 | 9 | type 10 | G[T] = object 11 | inodes: Table[int, T] 12 | rnodes: Table[T, int] 13 | 14 | var g: G[string] 15 | echo g.rnodes["foo"] 16 | -------------------------------------------------------------------------------- /tests/generics/t6637.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | Grid2D*[I: SomeInteger, w, h: static[I], T] = object 4 | grid: array[w, array[h, T]] 5 | Grid2DIns = Grid2D[int, 2, 3, uint8] 6 | 7 | let a = Grid2DIns() 8 | doAssert a.grid.len == 2 9 | doAssert a.grid[0].len == 3 10 | -------------------------------------------------------------------------------- /tests/js/tjshello.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim $target $options --stackTrace:off --lineTrace:off $file" 3 | output: "Hello World" 4 | maxcodesize: 1000 5 | ccodecheck: "!@'function'" 6 | """ 7 | 8 | import jsconsole 9 | 10 | console.log "Hello World" 11 | -------------------------------------------------------------------------------- /tests/let/tlet.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'name' cannot be assigned to" 3 | line: "10" 4 | """ 5 | 6 | echo("What's your name? ") 7 | let name = readLine(stdin) 8 | while name == "": 9 | echo("Please tell me your name: ") 10 | name = readLine(stdin) 11 | -------------------------------------------------------------------------------- /tests/objects/m19342.c: -------------------------------------------------------------------------------- 1 | struct Node 2 | { 3 | int data[25]; 4 | }; 5 | 6 | 7 | struct Node hello(int name) { 8 | struct Node x = {999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9 | 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9, 10 | 1, 2, 3, 4, 5}; 11 | return x; 12 | } -------------------------------------------------------------------------------- /tests/objects/tdefaultrangetypescheck.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "conversion from int literal(0) to range 1..5(int) is invalid" 3 | line: 9 4 | """ 5 | 6 | type 7 | Point = object 8 | y: int 9 | x: range[1..5] = 0 10 | 11 | echo default(Point) 12 | -------------------------------------------------------------------------------- /tests/template/t13515.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | template test: bool = true 6 | 7 | # compiles: 8 | if not test: 9 | echo "wtf" 10 | 11 | # does not compile: 12 | template x = 13 | if not test: 14 | echo "wtf" 15 | 16 | x 17 | -------------------------------------------------------------------------------- /tests/vm/textensionmap.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #5237 3 | 4 | import tables 5 | import sets 6 | import sequtils 7 | 8 | 9 | const EXTENSIONMAP = { 10 | "c": @["*.c", "*.h"], 11 | }.toTable() 12 | 13 | const EXTENSIONS = toHashSet(concat(toSeq(EXTENSIONMAP.values()))) 14 | -------------------------------------------------------------------------------- /tests/ambsym/tambsym.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "ambiguous identifier" 3 | file: "tambsym.nim" 4 | line: 11 5 | """ 6 | # Test ambiguous symbols 7 | 8 | import mambsym1, mambsym2 9 | 10 | var 11 | v: TExport #ERROR_MSG ambiguous identifier 12 | 13 | v = y 14 | -------------------------------------------------------------------------------- /tests/assert/tuserassert.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "x == 45ugh" 3 | """ 4 | 5 | template myAssert(cond: untyped) = 6 | when 3 <= 3: 7 | let c = cond.astToStr 8 | if not cond: 9 | echo c, "ugh" 10 | 11 | var x = 454 12 | myAssert(x == 45) 13 | 14 | -------------------------------------------------------------------------------- /tests/ccgbugs/tmissing_ccgtrav_unique_type.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #3794 3 | 4 | 5 | import options 6 | 7 | proc getRef*(): Option[int] = 8 | return none(int) 9 | 10 | proc getChild*() = 11 | let iter = iterator (): int {.closure.} = 12 | let reference = getRef() 13 | -------------------------------------------------------------------------------- /tests/cpp/t9013.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | cmd: "nim $target --debugger:native $options $file" 4 | """ 5 | 6 | # The --debugger switch is needed in order to enable the defined(nimTypeNames) 7 | # code path in hti.nim 8 | import typeinfo 9 | var tt: Any 10 | -------------------------------------------------------------------------------- /tests/enum/tenumitems2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "A\nB\nC" 3 | """ 4 | 5 | type TAlphabet = enum 6 | A, B, C 7 | 8 | iterator items(E: typedesc[enum]): E = 9 | for v in low(E)..high(E): 10 | yield v 11 | 12 | for c in TAlphabet: 13 | echo($c) 14 | 15 | -------------------------------------------------------------------------------- /tests/iter/titer5.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "abcxyz" 3 | """ 4 | # Test method call syntax for iterators: 5 | import strutils 6 | 7 | const lines = """abc xyz""" 8 | 9 | for x in lines.split(): 10 | stdout.write(x) 11 | 12 | #OUT abcxyz 13 | stdout.write "\n" 14 | -------------------------------------------------------------------------------- /tests/lent/tnot_allowed_lent2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'x' cannot be assigned to" 3 | line: 10 4 | """ 5 | 6 | proc bug14498 = 7 | var a = @['a', 'b', 'c', 'd', 'e', 'f'] 8 | 9 | for x in a: 10 | x = 'c' 11 | 12 | echo a 13 | 14 | bug14498() 15 | -------------------------------------------------------------------------------- /tests/misc/tinit.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "Hello from module! Hello from main module!" 3 | """ 4 | # Test the new init section in modules 5 | 6 | import minit 7 | 8 | write(stdout, "Hello from main module!\n") 9 | #OUT Hello from module! Hello from main module! 10 | -------------------------------------------------------------------------------- /tests/nimdoc/t17615.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim doc -r $file" 3 | errormsg: "runnableExamples must appear before the first non-comment statement" 4 | line: 10 5 | """ 6 | 7 | func fn*() = 8 | ## foo 9 | discard 10 | runnableExamples: 11 | assert true 12 | -------------------------------------------------------------------------------- /tests/typerel/t8172.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot convert array[0..0, string] to varargs[string]" 3 | line: 11 4 | """ 5 | 6 | proc f(v: varargs[string]) = 7 | echo(v) 8 | 9 | f("b", "c") # Works 10 | f(["b", "c"]) # Works 11 | f("b", ["c"]) # Fails 12 | -------------------------------------------------------------------------------- /tests/typerel/ttypenovalue.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'typedesc[seq[tuple[title: string, body: string]]]' for var" 3 | line: 7 4 | """ 5 | 6 | proc crashAndBurn() = 7 | var stuff = seq[tuple[title, body: string]] 8 | 9 | 10 | crashAndBurn() 11 | -------------------------------------------------------------------------------- /tests/typerel/typedescs.nim: -------------------------------------------------------------------------------- 1 | # bug #1774 2 | proc p(T: typedesc) = discard 3 | 4 | p(type((5, 6))) # Compiles 5 | (type((5, 6))).p # Doesn't compile (SIGSEGV: Illegal storage access.) 6 | type T = type((5, 6)) # Doesn't compile (SIGSEGV: Illegal storage access.) 7 | 8 | -------------------------------------------------------------------------------- /nimsuggest/tests/tcallstrlit_highlight.nim: -------------------------------------------------------------------------------- 1 | func foo(s: string) = discard 2 | 3 | foo"string"#[!]# 4 | 5 | discard """ 6 | $nimsuggest --tester $file 7 | >highlight $1 8 | highlight;;skFunc;;1;;5;;3 9 | highlight;;skType;;1;;12;;6 10 | highlight;;skFunc;;3;;0;;3 11 | """ 12 | -------------------------------------------------------------------------------- /nimsuggest/tests/tsi_highlight.nim: -------------------------------------------------------------------------------- 1 | proc a: int = 0 2 | e_c_h_o#[!]# 3 | 4 | discard """ 5 | $nimsuggest --tester $file 6 | >highlight $1 7 | highlight;;skProc;;1;;5;;1 8 | highlight;;skType;;1;;8;;3 9 | highlight;;skResult;;1;;0;;0 10 | highlight;;skProc;;2;;0;;7 11 | """ 12 | -------------------------------------------------------------------------------- /tests/ccgbugs/tnocodegen_for_compiletime.nim: -------------------------------------------------------------------------------- 1 | # bug #1679 2 | import macros, tables, hashes 3 | proc hash(v: NimNode): Hash = 4 # performance is for suckers 4 | macro test(body: untyped) = 5 | var a = initCountTable[NimNode]() 6 | a.inc(body) 7 | 8 | test: 9 | 1 + 1 10 | -------------------------------------------------------------------------------- /tests/errmsgs/t10489_a.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'macro (body: untyped): untyped{.noSideEffect, gcsafe.}' for let. Did you mean to call the macro with '()'?" 3 | line: 9 4 | """ 5 | 6 | macro m(body: untyped): untyped = 7 | body 8 | 9 | let x1 = m 10 | -------------------------------------------------------------------------------- /tests/errmsgs/t10489_b.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'macro (body: untyped): untyped{.noSideEffect, gcsafe.}' for const. Did you mean to call the macro with '()'?" 3 | line: 9 4 | """ 5 | 6 | macro m(body: untyped): untyped = 7 | body 8 | 9 | const x2 = m 10 | -------------------------------------------------------------------------------- /tests/lexer/tunderscores.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid token: trailing underscore" 3 | file: "tunderscores.nim" 4 | line: 8 5 | """ 6 | # Bug #502670 7 | 8 | var ef_ = 3 #ERROR_MSG invalid token: _ 9 | var a__b = 1 10 | var c___d = 2 11 | echo(ab, cd, ef_) 12 | -------------------------------------------------------------------------------- /tests/manyloc/keineschweine/enet_server/nim.cfg: -------------------------------------------------------------------------------- 1 | path = ".." 2 | path = "../dependencies/sfml" 3 | path = "../dependencies/enet" 4 | path = "../dependencies/nake" 5 | path = "../dependencies/genpacket" 6 | path = "../lib" 7 | define = "noChipmunk" 8 | define = "noSFML" 9 | 10 | -------------------------------------------------------------------------------- /tests/modules/tambig_range.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "ambiguous identifier: 'range' -- use one of the following:" 3 | line: "13" 4 | """ 5 | 6 | import mrange 7 | 8 | # bug #6965 9 | type SomeObj = object 10 | s: set[int8] 11 | 12 | # bug #6726 13 | range() 14 | -------------------------------------------------------------------------------- /tests/modules/texport.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "my object68" 3 | """ 4 | 5 | import mexporta 6 | 7 | # bug #1029: 8 | from nativesockets import accept 9 | 10 | # B.TMyObject has been imported implicitly here: 11 | var x: TMyObject 12 | echo($x, q(0), q"0") 13 | 14 | -------------------------------------------------------------------------------- /tests/modules/tmismatchedvisibility.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "public implementation 'tmismatchedvisibility.foo(a: int)' has non-public forward declaration at " 3 | line: 8 4 | """ 5 | 6 | proc foo(a: int): int 7 | 8 | proc foo*(a: int): int = 9 | result = a + a 10 | -------------------------------------------------------------------------------- /tests/stdlib/tos_unc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | disabled: "posix" 3 | """ 4 | 5 | # bug 10952, UNC paths 6 | import os 7 | import std/assertions 8 | 9 | doAssert r"\\hostname\foo\bar" / "baz" == r"\\hostname\foo\bar\baz" 10 | doAssert r"\\?\C:\foo" / "bar" == r"\\?\C:\foo\bar" 11 | -------------------------------------------------------------------------------- /tests/testament/tinlinemsg.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--errorMax:0 --styleCheck:error" 3 | """ 4 | 5 | proc generic_proc*[T](a_a: int) = #[tt.Error 6 | ^ 'generic_proc' should be: 'genericProc'; tt.Error 7 | ^ 'a_a' should be: 'aA' ]# 8 | discard 9 | -------------------------------------------------------------------------------- /tests/tuples/t12892.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | disabled: i386 3 | """ 4 | 5 | template works[T](): auto = T.high - 1 6 | template breaks[T](): auto = (T.high - 1, true) 7 | doAssert $works[uint]() == "18446744073709551614" 8 | doAssert $breaks[uint]() == "(18446744073709551614, true)" 9 | -------------------------------------------------------------------------------- /config/build_config.txt: -------------------------------------------------------------------------------- 1 | nim_comment="key-value pairs for windows/posix bootstrapping build scripts" 2 | nim_csourcesDir=csources_v1 3 | nim_csourcesUrl=https://github.com/nim-lang/csources_v1.git 4 | nim_csourcesBranch=master 5 | nim_csourcesHash=561b417c65791cd8356b5f73620914ceff845d10 6 | -------------------------------------------------------------------------------- /nimsuggest/tests/tcursor_at_end.nim: -------------------------------------------------------------------------------- 1 | # test we get some suggestion at the end of the file 2 | 3 | discard """ 4 | $nimsuggest --tester $file 5 | >sug $1 6 | sug;;skProc;;tcursor_at_end.main;;proc ();;$file;;10;;5;;"";;* 7 | """ 8 | 9 | 10 | proc main = discard 11 | 12 | #[!]# 13 | -------------------------------------------------------------------------------- /nimsuggest/tests/tno_deref.nim: -------------------------------------------------------------------------------- 1 | 2 | var x: ptr int 3 | 4 | proc foo(y: ptr int) = 5 | discard 6 | 7 | x.#[!]# 8 | 9 | discard """ 10 | $nimsuggest --tester $file 11 | >sug $1 12 | sug;;skProc;;tno_deref.foo;;proc (y: ptr int)*;;$file;;4;;5;;"";;100;;None 13 | * 14 | """ 15 | -------------------------------------------------------------------------------- /tests/arc/timportedobj.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc $file" 3 | action: "compile" 4 | """ 5 | 6 | # bug #13269 7 | 8 | import posix 9 | proc foo*() = 10 | var last = newSeq[Stat]() 11 | var next = last 12 | for i in 0..3: 13 | last = next 14 | foo() 15 | -------------------------------------------------------------------------------- /tests/async/tmultisync.nim: -------------------------------------------------------------------------------- 1 | import asyncdispatch, net, asyncnet 2 | 3 | proc recvTwice(socket: Socket | AsyncSocket, 4 | size: int): Future[string] {.multisync.} = 5 | var x = await socket.recv(size) 6 | var y = await socket.recv(size+1) 7 | return x & "aboo" & y 8 | 9 | -------------------------------------------------------------------------------- /tests/ccgbugs/tassign_nil_strings.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc" 3 | output: "Hello" 4 | ccodecheck: "\\i@'a = ((NimStringDesc*) NIM_NIL)'" 5 | """ 6 | 7 | proc main() = 8 | var a = "Hello" 9 | echo a 10 | a = "" 11 | doAssert a.len == 0 12 | 13 | main() 14 | -------------------------------------------------------------------------------- /tests/destructor/tsetjmp_raise.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "index 2 not in 0 .. 0 [IndexDefect]" 3 | exitcode: 1 4 | cmd: "nim c --gc:arc --exceptions:setjmp $file" 5 | """ 6 | 7 | # bug #12961 8 | # --gc:arc --exceptions:setjmp 9 | let a = @[1] 10 | echo a[2] 11 | 12 | -------------------------------------------------------------------------------- /tests/js/tcodegendeclproc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | -1 4 | 8 5 | ''' 6 | ccodecheck: "'console.log(-1); function fac_' \\d+ '(n_' \\d+ ')'" 7 | """ 8 | proc fac(n: int): int {.codegenDecl: "console.log(-1); function $2($3)".} = 9 | return n 10 | 11 | echo fac(8) 12 | -------------------------------------------------------------------------------- /tests/range/tsubrange2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "value out of range: 50 notin 0 .. 40 [RangeDefect]" 3 | exitcode: "1" 4 | """ 5 | 6 | type 7 | TRange = range[0..40] 8 | 9 | proc p(r: TRange) = 10 | discard 11 | 12 | var 13 | r: TRange 14 | y = 50 15 | p y 16 | -------------------------------------------------------------------------------- /tests/stdlib/tcmdline.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c js" 3 | joinable: false 4 | """ 5 | 6 | import std/os 7 | import std/assertions 8 | 9 | var params = paramCount() 10 | doAssert params == 0 11 | doAssert paramStr(0).len > 0 12 | doAssert commandLineParams().len == 0 13 | -------------------------------------------------------------------------------- /tests/template/tinnerouterproc.nim: -------------------------------------------------------------------------------- 1 | block: # #20002 2 | proc bar(x: int): int = 10 3 | template foo = 4 | proc bar(x: int): int {.gensym.} = x + 2 5 | doAssert bar(3) == 5 6 | discard 3.bar # evaluates to 10 but only check if it compiles for now 7 | block: 8 | foo() 9 | -------------------------------------------------------------------------------- /tests/typerel/typalias.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | TMyObj = TYourObj 4 | TYourObj = object of RootObj 5 | x, y: int 6 | 7 | proc init: TYourObj = 8 | result.x = 0 9 | result.y = -1 10 | 11 | proc f(x: var TYourObj) = 12 | discard 13 | 14 | var m: TMyObj = init() 15 | f(m) 16 | -------------------------------------------------------------------------------- /tests/types/tassignemptytuple.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot infer the type of the tuple" 3 | file: "tassignemptytuple.nim" 4 | line: 11 5 | """ 6 | 7 | var 8 | foo: seq[int] 9 | bar: tuple[a: seq[int], b: set[char]] 10 | 11 | (foo, bar) = (@[], (@[], {})) 12 | -------------------------------------------------------------------------------- /tests/vm/t2574.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot call method eval at compile time" 3 | line: 14 4 | """ 5 | 6 | type 7 | PExpr = ref object of RootObj 8 | 9 | method eval(e: PExpr): int = 10 | discard 11 | 12 | static: 13 | let x = PExpr() 14 | discard x.eval 15 | -------------------------------------------------------------------------------- /tests/vm/tconstprocassignments.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | 100 4 | 100 5 | ''' 6 | """ 7 | 8 | proc f():int {.compileTime.} = 100 9 | 10 | const F = f 11 | echo F() 12 | 13 | const G = proc ():int = 14 | let x = f 15 | let y = x 16 | y() 17 | 18 | echo G() 19 | -------------------------------------------------------------------------------- /tests/ccgbugs/t8967.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp" 3 | """ 4 | 5 | import marshal 6 | 7 | template main() = 8 | let orig: set[char] = {'A'..'Z'} 9 | let m = $$orig 10 | let old = to[set[char]](m) 11 | doAssert orig - old == {} 12 | 13 | static: main() 14 | main() 15 | -------------------------------------------------------------------------------- /tests/closure/tinvalidclosure5.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'A = proc (){.nimcall.}'" 3 | line: 9 4 | """ 5 | 6 | type A = proc() {.nimcall.} 7 | proc main = 8 | let b = 1 9 | let a: A = proc() = echo b 10 | 11 | -------------------------------------------------------------------------------- /tests/converter/ttypeconverter1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''foo 3 | true''' 4 | """ 5 | 6 | converter p(i: int): bool = return i != 0 7 | 8 | if 1: 9 | echo if 4: "foo" else: "barr" 10 | while 0: 11 | echo "bar" 12 | 13 | var a: array[3, bool] 14 | a[0] = 3 15 | echo a[0] 16 | -------------------------------------------------------------------------------- /tests/effects/tsidee2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "5" 3 | """ 4 | 5 | var 6 | global: int 7 | 8 | proc dontcare(x: int): int = return x 9 | 10 | proc SideEffectLyer(x, y: int): int {.noSideEffect.} = 11 | return x + y + dontcare(x) 12 | 13 | echo SideEffectLyer(1, 3) #OUT 5 14 | -------------------------------------------------------------------------------- /tests/errmsgs/t19882.nim: -------------------------------------------------------------------------------- 1 | 2 | discard """ 3 | errormsg: "cannot instantiate 'A[T, P]' inside of type definition: 'init'; Maybe generic arguments are missing?" 4 | """ 5 | type A[T,P] = object 6 | b:T 7 | c:P 8 | proc init(): ref A = 9 | new(result) 10 | var a = init() 11 | -------------------------------------------------------------------------------- /tests/exception/texcsub.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "caught!" 3 | """ 4 | # Test inheritance for exception matching: 5 | 6 | try: 7 | raise newException(OSError, "dummy message") 8 | except Exception: 9 | echo "caught!" 10 | except: 11 | echo "wtf!?" 12 | 13 | #OUT caught! 14 | -------------------------------------------------------------------------------- /tests/importalls/m4.nim: -------------------------------------------------------------------------------- 1 | {.warning[UnusedImport]: off.} # xxx bug: this shouldn't be needed since we have `export m3` 2 | import ./m3 {.all.} 3 | import ./m3 as m3b 4 | export m3b 5 | export m3h3 6 | export m3.m3h4 7 | 8 | import ./m2 {.all.} as m2b 9 | export m2b except bar3 10 | 11 | -------------------------------------------------------------------------------- /tests/importalls/mt5.nim: -------------------------------------------------------------------------------- 1 | import ./m1 {.all.} as m2 except foo1 2 | doAssert foo2 == 2 3 | doAssert not compiles(foo1) 4 | doAssert m2.foo1 == 2 5 | doAssert compiles(m2.foo1) 6 | 7 | from system {.all.} as s import ThisIsSystem 8 | doAssert ThisIsSystem 9 | doAssert s.ThisIsSystem 10 | -------------------------------------------------------------------------------- /tests/misc/tinout.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | file: "tinout.nim" 4 | line: 12 5 | """ 6 | # Test in out checking for parameters 7 | 8 | proc abc(x: var int) = 9 | x = 0 10 | 11 | proc b() = 12 | abc(3) #ERROR 13 | 14 | b() 15 | -------------------------------------------------------------------------------- /tests/parser/tinvcolonlocation1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expected: ':', but got: 'echo'" 3 | file: "tinvcolonlocation1.nim" 4 | line: 8 5 | column: 7 6 | """ 7 | try #<- missing ':' 8 | echo "try" 9 | except: 10 | echo "except" 11 | finally: 12 | echo "finally" 13 | -------------------------------------------------------------------------------- /tests/parser/tinvcolonlocation3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expected: ':', but got: 'echo'" 3 | file: "tinvcolonlocation3.nim" 4 | line: 12 5 | column: 7 6 | """ 7 | try: 8 | echo "try" 9 | except: 10 | echo "except" 11 | finally #<- missing ':' 12 | echo "finally" 13 | -------------------------------------------------------------------------------- /tests/stdlib/tmemfiles1.nim: -------------------------------------------------------------------------------- 1 | import memfiles, os 2 | import std/syncio 3 | 4 | var 5 | mm: MemFile 6 | fn = "test.mmap" 7 | # Create a new file 8 | mm = memfiles.open(fn, mode = fmReadWrite, newFileSize = 20) 9 | mm.close() 10 | # mm.close() 11 | if fileExists(fn): removeFile(fn) 12 | -------------------------------------------------------------------------------- /tests/stdlib/tparseuints.nim: -------------------------------------------------------------------------------- 1 | import unittest, strutils 2 | 3 | block: # parseutils 4 | check: parseBiggestUInt("0") == 0'u64 5 | check: parseBiggestUInt("18446744073709551615") == 0xFFFF_FFFF_FFFF_FFFF'u64 6 | expect(ValueError): 7 | discard parseBiggestUInt("18446744073709551616") 8 | -------------------------------------------------------------------------------- /tests/untestable/network/README.md: -------------------------------------------------------------------------------- 1 | This directory contains tests that require networking and cannot be run in CI. 2 | 3 | The tests can be run manually during development using: 4 | ```nim 5 | ./koch tests cat untestable/network/stdlib 6 | ``` 7 | 8 | The directory structure mimics tests/ 9 | -------------------------------------------------------------------------------- /tests/varres/tvarres1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'bla' escapes its stack frame; context: 'bla'" 3 | file: "tvarres1.nim" 4 | line: 12 5 | """ 6 | 7 | var 8 | g = 5 9 | 10 | proc p(): var int = 11 | var bla: int 12 | result = bla 13 | 14 | p() = 45 15 | 16 | echo g 17 | -------------------------------------------------------------------------------- /tests/async/t15148.nim: -------------------------------------------------------------------------------- 1 | import asyncdispatch, asyncfile, os 2 | 3 | const Filename = "t15148.txt" 4 | 5 | proc saveEmpty() {.async.} = 6 | let 7 | text = "" 8 | file = openAsync(Filename, fmWrite) 9 | await file.write(text) 10 | file.close() 11 | 12 | waitFor saveEmpty() 13 | -------------------------------------------------------------------------------- /tests/ccgbugs/t6279.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c -r -d:fulldebug -d:smokeCycles --gc:refc $file" 3 | output: '''@["a"]''' 4 | """ 5 | 6 | # bug #6279 7 | var foo = newSeq[tuple[a: seq[string], b: seq[string]]]() 8 | foo.add((@["a"], @["b"])) 9 | echo foo[0].a # Crashes on this line 10 | -------------------------------------------------------------------------------- /tests/cpp/t4834.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | """ 4 | 5 | # issue #4834 6 | block: 7 | defer: 8 | let x = 0 9 | 10 | 11 | proc main() = 12 | block: 13 | defer: 14 | raise newException(Exception, "foo") 15 | 16 | doAssertRaises(Exception): 17 | main() 18 | --------------------------------------------------------------------------------