├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .vscode └── settings.json ├── Cargo.lock ├── Cargo.toml ├── LICENSE.md ├── README.md ├── bench ├── alloc │ └── alloc.dora ├── binarytrees │ ├── .gitignore │ ├── README.md │ ├── bench.log │ ├── bench.sh │ ├── binarytrees-mt.dora │ ├── binarytrees.dora │ ├── binarytrees.go │ ├── binarytrees.java │ ├── binarytrees.js │ └── binarytrees.pl ├── falsesharing │ └── falsesharing.dora ├── fannkuchredux │ ├── README.md │ ├── bench.log │ ├── bench.sh │ ├── fannkuchredux.dora │ ├── fannkuchredux.java │ ├── fannkuchredux.js │ └── fannkuchredux.pl ├── gc │ ├── alloc_garbage.dora │ └── alloc_linked_list.dora ├── gcbench │ └── gcbench.dora ├── gcold │ ├── gcold.dora │ └── gcold.java ├── mandelbrot │ ├── mandelbrot.dora │ ├── mandelbrot.java │ └── mandelbrot_out ├── nbody │ ├── nbody.dora │ ├── nbody.java │ └── output.txt ├── richards │ ├── richards.dora │ └── richards.js ├── splay │ ├── splay.dora │ └── splay.js └── splunc │ └── splunc.dora ├── dora-asm ├── Cargo.toml └── src │ ├── arm64.rs │ ├── lib.rs │ └── x64.rs ├── dora-bytecode ├── Cargo.toml └── src │ ├── data.rs │ ├── display.rs │ ├── dumper.rs │ ├── lib.rs │ ├── program.rs │ ├── reader.rs │ ├── serializer.rs │ ├── tests.rs │ ├── ty.rs │ └── writer.rs ├── dora-frontend ├── Cargo.toml └── src │ ├── access.rs │ ├── aliasck.rs │ ├── clsdefck.rs │ ├── constdefck.rs │ ├── enumck.rs │ ├── error.rs │ ├── error │ ├── diag.rs │ └── msg.rs │ ├── exhaustiveness.rs │ ├── extensiondefck.rs │ ├── fctdefck.rs │ ├── generator.rs │ ├── generator │ ├── bytecode.rs │ ├── expr.rs │ └── tests.rs │ ├── globaldefck.rs │ ├── impldefck.rs │ ├── interner.rs │ ├── lib.rs │ ├── parsety.rs │ ├── path.rs │ ├── program_emitter.rs │ ├── program_parser.rs │ ├── readty.rs │ ├── returnck.rs │ ├── sema.rs │ ├── sema │ ├── aliases.rs │ ├── classes.rs │ ├── consts.rs │ ├── elements.rs │ ├── enums.rs │ ├── extensions.rs │ ├── functions.rs │ ├── globals.rs │ ├── impl_matching.rs │ ├── impls.rs │ ├── known.rs │ ├── matching.rs │ ├── modules.rs │ ├── packages.rs │ ├── source_files.rs │ ├── src.rs │ ├── structs.rs │ ├── traits.rs │ ├── tuples.rs │ ├── type_params.rs │ └── uses.rs │ ├── specialize.rs │ ├── stdlib_lookup.rs │ ├── structdefck.rs │ ├── sym.rs │ ├── traitdefck.rs │ ├── ty.rs │ ├── typeck.rs │ ├── typeck │ ├── call.rs │ ├── constck.rs │ ├── control.rs │ ├── expr.rs │ ├── function.rs │ ├── lookup.rs │ ├── stmt.rs │ ├── tests.rs │ └── type_params.rs │ ├── typedefck.rs │ └── useck.rs ├── dora-language-server ├── Cargo.toml └── src │ ├── main.rs │ └── symbols.rs ├── dora-parser ├── .gitignore ├── Cargo.toml └── src │ ├── ast.rs │ ├── ast │ ├── dump.rs │ └── visit.rs │ ├── error.rs │ ├── green.rs │ ├── lexer.rs │ ├── lib.rs │ ├── parser.rs │ ├── parser │ └── tests.rs │ ├── span.rs │ └── token.rs ├── dora-runtime ├── Cargo.toml └── src │ ├── boots.rs │ ├── boots │ ├── data.rs │ ├── deserializer.rs │ └── serializer.rs │ ├── cannon.rs │ ├── cannon │ ├── asm.rs │ └── codegen.rs │ ├── compiler.rs │ ├── compiler │ ├── aot.rs │ ├── codegen.rs │ ├── dora_entry_trampoline.rs │ ├── lazy_compilation_stub.rs │ ├── runtime_entry_trampoline.rs │ └── trait_object_thunk.rs │ ├── cpu.rs │ ├── cpu │ ├── arm64.rs │ └── x64.rs │ ├── disassembler.rs │ ├── disassembler │ ├── capstone.rs │ └── none.rs │ ├── gc.rs │ ├── gc │ ├── allocator.rs │ ├── bump.rs │ ├── code.rs │ ├── copy.rs │ ├── freelist.rs │ ├── marking.rs │ ├── metaspace.rs │ ├── pmarking.rs │ ├── root.rs │ ├── space.rs │ ├── sweep.rs │ ├── swiper.rs │ ├── swiper │ │ ├── controller.rs │ │ ├── full.rs │ │ ├── heap.rs │ │ ├── large.rs │ │ ├── minor.rs │ │ ├── old.rs │ │ ├── readonly.rs │ │ ├── sweeper.rs │ │ ├── verify.rs │ │ └── young.rs │ ├── tlab.rs │ ├── worklist.rs │ └── zero.rs │ ├── handle.rs │ ├── lib.rs │ ├── masm.rs │ ├── masm │ ├── arm64.rs │ └── x64.rs │ ├── mem.rs │ ├── mirror.rs │ ├── mirror │ └── string.rs │ ├── mode.rs │ ├── os.rs │ ├── os │ ├── allocator.rs │ ├── page.rs │ └── perf.rs │ ├── safepoint.rs │ ├── shape.rs │ ├── size.rs │ ├── snapshot.rs │ ├── stack.rs │ ├── stdlib.rs │ ├── stdlib │ └── io.rs │ ├── threads.rs │ ├── timer.rs │ ├── utils.rs │ ├── vm.rs │ └── vm │ ├── classes.rs │ ├── code.rs │ ├── code_map.rs │ ├── compilation.rs │ ├── enums.rs │ ├── extensions.rs │ ├── flags.rs │ ├── globals.rs │ ├── impls.rs │ ├── initialize.rs │ ├── known.rs │ ├── natives.rs │ ├── specialize.rs │ ├── stdlib_lookup.rs │ ├── structs.rs │ ├── tuples.rs │ ├── ty.rs │ └── waitlists.rs ├── dora-sema-fuzzer ├── Cargo.toml └── src │ └── main.rs ├── dora-token-fuzzer ├── Cargo.toml └── src │ └── main.rs ├── dora ├── .gitignore ├── Cargo.toml └── src │ ├── driver.rs │ ├── driver │ ├── flags.rs │ └── start.rs │ └── main.rs ├── editors └── code │ ├── .eslintrc.json │ ├── .gitignore │ ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json │ ├── .vscodeignore │ ├── README.md │ ├── language-configuration.json │ ├── package-lock.json │ ├── package.json │ ├── src │ └── extension.ts │ ├── syntaxes │ └── dora.tmLanguage.json │ └── tsconfig.json ├── pkgs ├── boots │ ├── assembler.dora │ ├── assembler │ │ ├── arm64.dora │ │ └── x64.dora │ ├── boots.dora │ ├── bytecode.dora │ ├── bytecode │ │ ├── builder.dora │ │ ├── data.dora │ │ ├── deserializer.dora │ │ ├── dump.dora │ │ ├── instruction.dora │ │ ├── opcode.dora │ │ ├── program.dora │ │ ├── reader.dora │ │ └── tests.dora │ ├── cfg_simplification.dora │ ├── codegen.dora │ ├── codegen │ │ ├── arm64.dora │ │ └── x64.dora │ ├── compilation.dora │ ├── dead_code_elimination.dora │ ├── deserializer.dora │ ├── dominator.dora │ ├── dora-project.json │ ├── graph.dora │ ├── graph │ │ ├── builder.dora │ │ ├── dump.dora │ │ ├── html.dora │ │ ├── reader.dora │ │ ├── tests.dora │ │ ├── ty.dora │ │ └── verifier.dora │ ├── graph_builder.dora │ ├── inlining.dora │ ├── interface.dora │ ├── liveness.dora │ ├── load_elimination.dora │ ├── location.dora │ ├── prepare_regalloc.dora │ ├── regalloc.dora │ ├── resolver.dora │ ├── serializer.dora │ ├── sparse_set.dora │ ├── specialize.dora │ └── stackalloc.dora └── std │ ├── collections.dora │ ├── io.dora │ ├── primitives.dora │ ├── rand.dora │ ├── std.dora │ ├── string.dora │ ├── thread.dora │ └── traits.dora ├── rust-toolchain ├── tests ├── alias │ ├── alias-generic1.dora │ ├── alias-int1.dora │ └── alias-trait1.dora ├── array │ ├── array-compare-panic1.dora │ ├── array-compare-panic2.dora │ ├── array-compare-panic3.dora │ ├── array-compare-panic4.dora │ ├── array-compare.dora │ ├── array-contains.dora │ ├── array-enumerate1.dora │ ├── array-enumerate2.dora │ ├── array-equals.dora │ ├── array-field1.dora │ ├── array-field2.dora │ ├── array-for-tuple.dora │ ├── array-for1.dora │ ├── array-for3.dora │ ├── array-gc.dora │ ├── array-get.dora │ ├── array-length.dora │ ├── array-list1.dora │ ├── array-new.dora │ ├── array-rest1.dora │ ├── array-rest2.dora │ ├── array-rest3.dora │ ├── array-rest4.dora │ ├── array-rest5.dora │ ├── array-set.dora │ ├── array-sortStable.dora │ ├── array-store-struct1.dora │ ├── array-syntax1.dora │ ├── array-toString.dora │ ├── array-zero.dora │ ├── array1.dora │ ├── array10.dora │ ├── array13.dora │ ├── array14.dora │ ├── array2.dora │ ├── array3.dora │ ├── array4.dora │ ├── array5.dora │ ├── array6.dora │ ├── array7.dora │ ├── array8.dora │ └── array9.dora ├── atomic │ ├── atomic-int32-compare-exchange1.dora │ ├── atomic-int32-exchange1.dora │ ├── atomic-int32-fetch-add1.dora │ ├── atomic-int32-get1.dora │ ├── atomic-int32-thread1.dora │ ├── atomic-int64-compare-exchange1.dora │ ├── atomic-int64-exchange1.dora │ ├── atomic-int64-fetch-add1.dora │ └── atomic-int64-get1.dora ├── bench │ ├── binarytrees-mt1.dora │ ├── binarytrees-mt1.stdout │ ├── binarytrees1.dora │ ├── binarytrees1.stdout │ ├── binarytrees2.dora │ ├── binarytrees2.stdout │ ├── binarytrees3.dora │ ├── binarytrees3.stdout │ ├── binarytrees4.dora │ ├── binarytrees4.stdout │ ├── binarytrees5.dora │ ├── binarytrees5.stdout │ ├── binarytrees5stress.dora │ ├── binarytrees5stress.stdout │ ├── binarytrees6.dora │ ├── binarytrees6.stdout │ ├── fannkuchredux1.dora │ ├── fannkuchredux2.dora │ ├── fannkuchredux3.dora │ ├── fannkuchredux4.dora │ ├── fannkuchredux5.dora │ ├── fannkuchredux6.dora │ ├── fannkuchredux7.dora │ ├── fannkuchredux8.dora │ ├── fannkuchredux9.dora │ ├── gcbench1.dora │ ├── gcold1.dora │ ├── nbody10.dora │ ├── richards1.dora │ ├── splay1.dora │ └── splunc1.dora ├── boots │ ├── add-float32.dora │ ├── add-float64.dora │ ├── add-int32-overflow.dora │ ├── add-int32-same.dora │ ├── add-int32.dora │ ├── add-int64-overflow.dora │ ├── add-int64.dora │ ├── and-int32.dora │ ├── and-int64.dora │ ├── array-length.dora │ ├── array-load-enum1.dora │ ├── array-load-enum2.dora │ ├── array-load-float32.dora │ ├── array-load-float64.dora │ ├── array-load-int32.dora │ ├── array-load-int64.dora │ ├── array-load-ptr.dora │ ├── array-load-struct1.dora │ ├── array-load-struct2.dora │ ├── array-load-tuple1.dora │ ├── array-load-uint8.dora │ ├── array-new1.dora │ ├── array-new2.dora │ ├── array-new3.dora │ ├── array-new4.dora │ ├── array-store-enum1.dora │ ├── array-store-enum2.dora │ ├── array-store-float32.dora │ ├── array-store-float64.dora │ ├── array-store-int32.dora │ ├── array-store-int64.dora │ ├── array-store-pointer.dora │ ├── array-store-struct1.dora │ ├── array-store-struct2.dora │ ├── array-store-struct3.dora │ ├── array-store-tuple1.dora │ ├── array-store-uint8.dora │ ├── assert1.dora │ ├── assert2.dora │ ├── call-direct-bool-arg.dora │ ├── call-direct-intrinsic.dora │ ├── call-direct-no-args.dora │ ├── call-lambda-noargs.dora │ ├── call-lambda-tuple1.dora │ ├── call-lambda-tuple2.dora │ ├── call-static-enum1.dora │ ├── call-static-enum2.dora │ ├── call-static-float32.dora │ ├── call-static-int64-arg.dora │ ├── call-static-int64-arg2.dora │ ├── call-static-int64-return.dora │ ├── call-static-intrinsic.dora │ ├── call-static-noargs.dora │ ├── call-static-stackargs1.dora │ ├── call-static-stackargs2.dora │ ├── call-static-stackargs3.dora │ ├── call-static-stackargs4.dora │ ├── call-static-stackargs5.dora │ ├── call-static-stackargs6.dora │ ├── call-static-stackargs7.dora │ ├── call-static-struct-arg.dora │ ├── call-static-struct.dora │ ├── call-static-tuple-arg.dora │ ├── call-static-tuple1.dora │ ├── call-static-tuple2.dora │ ├── call-static-tuple3.dora │ ├── call-static-twice.dora │ ├── call-virtual-noargs.dora │ ├── call-virtual-tuple1.dora │ ├── call-virtual-tuple2.dora │ ├── class-load-enum1.dora │ ├── class-load-enum2.dora │ ├── class-load-float32.dora │ ├── class-load-float64.dora │ ├── class-load-int32.dora │ ├── class-load-int64-2.dora │ ├── class-load-int64.dora │ ├── class-load-pointer.dora │ ├── class-load-struct1.dora │ ├── class-load-tuple1.dora │ ├── class-load-uint8.dora │ ├── class-new1.dora │ ├── class-new2.dora │ ├── class-new3.dora │ ├── class-new4.dora │ ├── class-new5.dora │ ├── class-new6.dora │ ├── class-new7.dora │ ├── class-store-bool.dora │ ├── class-store-enum1.dora │ ├── class-store-enum2.dora │ ├── class-store-float32.dora │ ├── class-store-float64.dora │ ├── class-store-int32.dora │ ├── class-store-int64.dora │ ├── class-store-lambda1.dora │ ├── class-store-pointer.dora │ ├── class-store-struct1.dora │ ├── class-store-struct2.dora │ ├── class-store-trait1.dora │ ├── class-store-uint8.dora │ ├── compare-float32.dora │ ├── compare-float64.dora │ ├── compare-int32.dora │ ├── compare-int64.dora │ ├── compare-ordering-float32.dora │ ├── compare-ordering-float64.dora │ ├── compare-ordering-int32.dora │ ├── compare-ordering-int64.dora │ ├── compare-ordering-uint8.dora │ ├── compare-uint8.dora │ ├── div-float32.dora │ ├── div-float64.dora │ ├── div-int64-divby0.dora │ ├── div-int64-overflow.dora │ ├── div-int64.dora │ ├── enum-eq1.dora │ ├── enum-match1.dora │ ├── enum-match2.dora │ ├── enum-match3.dora │ ├── enum-ne1.dora │ ├── enum-new1.dora │ ├── fail1.dora │ ├── gc1.dora │ ├── gc2.dora │ ├── gc3.dora │ ├── generic-add.dora │ ├── generic-direct-call1.dora │ ├── generic-return-id.dora │ ├── generic-static-call1.dora │ ├── global-load-enum1-uninit.dora │ ├── global-load-enum1.dora │ ├── global-load-enum2-uninit.dora │ ├── global-load-enum2.dora │ ├── global-load-float32-uninit.dora │ ├── global-load-float32.dora │ ├── global-load-float64-uninit.dora │ ├── global-load-float64.dora │ ├── global-load-gc1.dora │ ├── global-load-gc2.dora │ ├── global-load-gc3.dora │ ├── global-load-gc4.dora │ ├── global-load-int32-uninit.dora │ ├── global-load-int32.dora │ ├── global-load-int64-uninit.dora │ ├── global-load-int64.dora │ ├── global-load-ptr-uninit.dora │ ├── global-load-ptr.dora │ ├── global-load-struct1.dora │ ├── global-load-struct2.dora │ ├── global-load-tuple1.dora │ ├── global-load-uint8-uninit.dora │ ├── global-load-uint8.dora │ ├── global-store-enum1.dora │ ├── global-store-enum2.dora │ ├── global-store-float32.dora │ ├── global-store-float64.dora │ ├── global-store-int32.dora │ ├── global-store-int64.dora │ ├── global-store-ptr.dora │ ├── global-store-struct1.dora │ ├── global-store-tuple1.dora │ ├── global-store-uint8.dora │ ├── hello-world.dora │ ├── hello.dora │ ├── if-phi-critical.dora │ ├── if-phi-return-float32.dora │ ├── if-phi-return-float64-2.dora │ ├── if-phi-return-float64.dora │ ├── if-phi-return-int32-2.dora │ ├── if-phi-return-int32.dora │ ├── if-return.dora │ ├── inline-multiple-returns1.dora │ ├── inline-multiple-returns2.dora │ ├── inline-return-struct1.dora │ ├── inline-return-tuple1.dora │ ├── inline-return1.dora │ ├── inline1.dora │ ├── inline2.dora │ ├── inline3.dora │ ├── inline4.dora │ ├── int64-ops.dora │ ├── loop-increment-counter.dora │ ├── mod-int64-overflow.dora │ ├── mod-int64.dora │ ├── mul-float32.dora │ ├── mul-float64.dora │ ├── mul-int32-overflow.dora │ ├── mul-int32.dora │ ├── mul-int64-overflow.dora │ ├── mul-int64.dora │ ├── neg-float32.dora │ ├── neg-float64.dora │ ├── neg-int32-overflow.dora │ ├── neg-int32.dora │ ├── neg-int64-overflow.dora │ ├── neg-int64.dora │ ├── nested-loop1.dora │ ├── nested-loop2.dora │ ├── not-int32.dora │ ├── not-int64.dora │ ├── opt │ │ ├── array-length-twice.dora │ │ ├── global-multiple-loads-in-block1.dora │ │ ├── global-multiple-loads-in-block2.dora │ │ ├── if-const.dora │ │ ├── infinite-loop1.dora │ │ ├── inline-unreachable.dora │ │ └── option-get-or-panic.dora │ ├── option-match1.dora │ ├── option-match2.dora │ ├── option-match3.dora │ ├── option-new1.dora │ ├── option-new2.dora │ ├── option-new3.dora │ ├── or-int32.dora │ ├── or-int64.dora │ ├── result-match1.dora │ ├── result-new1.dora │ ├── return-bool-arg.dora │ ├── return-bool-const.dora │ ├── return-char-const.dora │ ├── return-float32-arg.dora │ ├── return-float32-const.dora │ ├── return-float64-arg.dora │ ├── return-float64-const.dora │ ├── return-int32-arg.dora │ ├── return-int32-const.dora │ ├── return-int64-arg.dora │ ├── return-int64-const.dora │ ├── return-lambda-context.dora │ ├── return-lambda.dora │ ├── return-pointer.dora │ ├── return-stackarg1.dora │ ├── return-stackarg2.dora │ ├── return-string-const.dora │ ├── return-struct-bool.dora │ ├── return-struct-char.dora │ ├── return-struct-float32.dora │ ├── return-struct-float64.dora │ ├── return-struct-int64.dora │ ├── return-struct-nested1.dora │ ├── return-struct-nested2.dora │ ├── return-struct-uint8.dora │ ├── return-tuple-nested1.dora │ ├── return-tuple-nested2.dora │ ├── return-tuple1.dora │ ├── return-uint8-const.dora │ ├── sar-int32.dora │ ├── sar-int64.dora │ ├── shl-int32.dora │ ├── shl-int64.dora │ ├── shr-int32.dora │ ├── shr-int64.dora │ ├── struct-load-enum1.dora │ ├── struct-load-enum2.dora │ ├── struct-load-int64.dora │ ├── struct-load-struct1.dora │ ├── struct-load-tuple1.dora │ ├── struct-new1.dora │ ├── struct-new2.dora │ ├── struct-new3.dora │ ├── struct-new4.dora │ ├── sub-float32.dora │ ├── sub-float64.dora │ ├── sub-int32-overflow.dora │ ├── sub-int32.dora │ ├── sub-int64-overflow.dora │ ├── sub-int64.dora │ ├── test.dora │ ├── trait-method1.dora │ ├── trait-new1.dora │ ├── tuple-load-int64.dora │ ├── tuple-load-struct1.dora │ ├── tuple-load-tuple1.dora │ ├── tuple-new1.dora │ ├── tuple-new2.dora │ ├── unreachable1.dora │ ├── unreachable2.dora │ ├── while-phi1.dora │ ├── while-phi2.dora │ ├── while-phi3.dora │ ├── while-phi4.dora │ ├── xor-int32.dora │ └── xor-int64.dora ├── cannon │ ├── abi1.dora │ ├── abi2.dora │ ├── abi3.dora │ ├── array1.dora │ ├── array2.dora │ ├── assert1.dora │ ├── basic1.dora │ ├── basic2.dora │ ├── bool1.dora │ ├── byte1.dora │ ├── char1.dora │ ├── enum1.dora │ ├── fct1.dora │ ├── fct2.dora │ ├── fct3.dora │ ├── fct4.dora │ ├── float32-1.dora │ ├── float64-1.dora │ ├── gc-in-compiler1.dora │ ├── gc-in-compiler2.dora │ ├── gc-in-compiler3.dora │ ├── int32-1.dora │ ├── int32-2.dora │ ├── int64-1.dora │ ├── int64-2.dora │ ├── load1.dora │ ├── load2.dora │ ├── neg-int32-overflow.dora │ ├── neg-int32-wrapping.dora │ ├── neg-int64-overflow.dora │ ├── neg-int64-wrapping.dora │ ├── store1.dora │ ├── store2.dora │ └── while1.dora ├── class │ ├── class-assign-unnamed1.dora │ ├── class-named-arg1.dora │ ├── new-class-syntax.dora │ ├── obj1.dora │ ├── obj2.dora │ ├── obj3.dora │ ├── obj4.dora │ ├── obj5.dora │ ├── obj6.dora │ └── obj7.dora ├── empty-world.dora ├── enum │ ├── enum-array1.dora │ ├── enum-array2.dora │ ├── enum-field1.dora │ ├── enum-field2.dora │ ├── enum-global1.dora │ ├── enum-int1.dora │ ├── enum-int2.dora │ ├── enum-match-underscore1.dora │ ├── enum-match1.dora │ ├── enum-match2.dora │ ├── enum-match3.dora │ ├── enum-match4.dora │ ├── enum-match5.dora │ ├── enum-match6.dora │ ├── enum-option1.dora │ ├── enum-option2.dora │ ├── enum-option3.dora │ ├── enum-option4.dora │ ├── enum-ptr1.dora │ ├── enum-ptr2.dora │ ├── enum-reg1.dora │ ├── enum-return1.dora │ ├── enum-tagged1.dora │ ├── enum-tagged2.dora │ └── enum-tuple1.dora ├── float │ ├── abs.dora │ ├── float-class.dora │ ├── float-global.dora │ ├── float-negative0.dora │ ├── float-parse.dora │ ├── float-scientific.dora │ ├── float-sqrt1.dora │ ├── float0.dora │ ├── float1.dora │ ├── float10.dora │ ├── float11.dora │ ├── float12.dora │ ├── float15.dora │ ├── float16.dora │ ├── float2.dora │ ├── float3.dora │ ├── float32-roundDown.dora │ ├── float32-roundHalfEven.dora │ ├── float32-roundToZero.dora │ ├── float32-roundUp.dora │ ├── float4.dora │ ├── float5.dora │ ├── float6.dora │ ├── float64-roundDown.dora │ ├── float64-roundHalfEven.dora │ ├── float64-roundToZero.dora │ ├── float64-roundUp.dora │ ├── float64_0.dora │ ├── float7.dora │ ├── float8.dora │ └── float9.dora ├── for │ ├── for-into-iterator-trait1.dora │ ├── for-iterator-generic1.dora │ ├── for-iterator-trait1.dora │ ├── for-range1.dora │ ├── for-range2.dora │ ├── for-range3.dora │ └── for-range4.dora ├── gc │ ├── gc1.dora │ ├── gc10.dora │ ├── gc11.dora │ ├── gc2.dora │ ├── gc3.dora │ ├── gc4.dora │ ├── gc5.dora │ ├── gc6.dora │ ├── gc7.dora │ ├── gc8.dora │ └── gc9.dora ├── generic │ ├── fct-and-class-generic1.dora │ ├── fct-and-class-generic2.dora │ ├── generic-add1.dora │ ├── generic-bitand1.dora │ ├── generic-bitor1.dora │ ├── generic-bitxor1.dora │ ├── generic-call1.dora │ ├── generic-call2.dora │ ├── generic-call3.dora │ ├── generic-call4.dora │ ├── generic-div1.dora │ ├── generic-equals1.dora │ ├── generic-extension1.dora │ ├── generic-extension2.dora │ ├── generic-extension3.dora │ ├── generic-fct-type-args1.dora │ ├── generic-fct-type-args2.dora │ ├── generic-ge1.dora │ ├── generic-gt1.dora │ ├── generic-hash-map-field.dora │ ├── generic-identity.dora │ ├── generic-impl1.dora │ ├── generic-le1.dora │ ├── generic-lt1.dora │ ├── generic-mod1.dora │ ├── generic-mul1.dora │ ├── generic-neg1.dora │ ├── generic-new-array1.dora │ ├── generic-not1.dora │ ├── generic-sar1.dora │ ├── generic-shl1.dora │ ├── generic-shr1.dora │ ├── generic-static-fct-type-args1.dora │ ├── generic-static-fct-type-args2.dora │ ├── generic-sub1.dora │ ├── generic-trait-method1.dora │ ├── generic-trait-static1.dora │ ├── generic-trait1.dora │ ├── generic-trait2.dora │ ├── generic1.dora │ ├── generic10.dora │ ├── generic12.dora │ ├── generic2.dora │ ├── generic4.dora │ ├── generic6.dora │ ├── generic7.dora │ ├── generic8.dora │ └── generic9.dora ├── hello-world.dora ├── impl │ ├── impl-alias1.dora │ ├── impl1.dora │ ├── impl2.dora │ ├── impl3.dora │ └── impl4.dora ├── int │ ├── div-zero1.dora │ ├── div-zero2.dora │ ├── expr1.dora │ ├── expr2.dora │ ├── expr4.dora │ ├── expr5.dora │ ├── expr6.dora │ ├── expr7.dora │ ├── int-count-bits.dora │ ├── int-shift-rotate.dora │ ├── int-unchecked-add1.dora │ ├── int-unchecked-mul1.dora │ ├── int-unchecked-sub1.dora │ ├── int1.dora │ ├── int2.dora │ ├── int32-overflow-add1.dora │ ├── int32-overflow-div1.dora │ ├── int32-overflow-mod1.dora │ ├── int32-overflow-mul1.dora │ ├── int32-overflow-sub1.dora │ ├── int32-tostring.dora │ ├── int64-1.dora │ ├── int64-2.dora │ ├── int64-3.dora │ ├── int64-4.dora │ ├── int64-5.dora │ ├── int64-count-bits.dora │ ├── int64-overflow-add1.dora │ ├── int64-overflow-div1.dora │ ├── int64-overflow-mod1.dora │ ├── int64-overflow-mul1.dora │ ├── int64-overflow-sub1.dora │ ├── int64-shift-rotate.dora │ ├── int64-tostring.dora │ ├── shl1.dora │ ├── shr1.dora │ └── zero.dora ├── io │ ├── 123.bin │ ├── abc.txt │ ├── file-create1.dora │ ├── file-read1.dora │ ├── read-as-bytes1.dora │ ├── read-as-string1.dora │ ├── stderr1.dora │ ├── stdout1.dora │ ├── tcp-server.dora │ ├── tcp-stream.dora │ ├── write-as-bytes1.dora │ └── write-as-string1.dora ├── lambda │ ├── lambda-call.dora │ ├── lambda-context-for1.dora │ ├── lambda-context-for2.dora │ ├── lambda-context-gc.dora │ ├── lambda-context-parameter-self.dora │ ├── lambda-context-parameter.dora │ ├── lambda-context-while1.dora │ ├── lambda-context1.dora │ ├── lambda-context2.dora │ ├── lambda-context3.dora │ ├── lambda-extension1.dora │ ├── lambda-generic1.dora │ ├── lambda-generic2.dora │ ├── lambda-impl1.dora │ ├── lambda-in-array.dora │ ├── lambda-in-class.dora │ ├── lambda-in-enum.dora │ ├── lambda-in-fct.dora │ ├── lambda-in-struct.dora │ ├── lambda-in-tuple.dora │ ├── lambda-new.dora │ └── lambda-self.dora ├── language │ ├── assert1.dora │ ├── assert2.dora │ ├── assert3.dora │ ├── block-expr-gc.dora │ ├── block1.dora │ ├── block2.dora │ ├── bool-tostring.dora │ ├── bool1.dora │ ├── bool2.dora │ ├── break1.dora │ ├── byte-tostring.dora │ ├── byte1.dora │ ├── byte3.dora │ ├── char1.dora │ ├── char2.dora │ ├── char3.dora │ ├── cmp1.dora │ ├── const1.dora │ ├── const2.dora │ ├── fn1.dora │ ├── fn2.dora │ ├── fn3.dora │ ├── fn5.dora │ ├── fn6.dora │ ├── fn7.dora │ ├── fn8.dora │ ├── global1.dora │ ├── global2.dora │ ├── global3.dora │ ├── global4.dora │ ├── global5.dora │ ├── global6.dora │ ├── global7.dora │ ├── global8.dora │ ├── global9.dora │ ├── if1.dora │ ├── is1.dora │ ├── match-guard1.dora │ ├── mod1.dora │ ├── noop-calls.dora │ ├── pattern-class1.dora │ ├── pattern-enum1.dora │ ├── pattern-enum2.dora │ ├── pattern-enum3.dora │ ├── pattern-expr1.dora │ ├── pattern-if1.dora │ ├── pattern-if2.dora │ ├── pattern-if3.dora │ ├── pattern-if4.dora │ ├── pattern-if5.dora │ ├── pattern-if6.dora │ ├── pattern-is1.dora │ ├── pattern-lit-bool1.dora │ ├── pattern-lit-bool2.dora │ ├── pattern-lit-char1.dora │ ├── pattern-lit-char2.dora │ ├── pattern-lit-float1.dora │ ├── pattern-lit-float2.dora │ ├── pattern-lit-int1.dora │ ├── pattern-lit-int2.dora │ ├── pattern-lit-string1.dora │ ├── pattern-lit-string2.dora │ ├── pattern-param-tuple1.dora │ ├── pattern-rest1.dora │ ├── pattern-rest2.dora │ ├── pattern-rest3.dora │ ├── pattern-rest4.dora │ ├── pattern-rest5.dora │ ├── pattern-struct1.dora │ ├── pattern-while1.dora │ ├── pattern-while2.dora │ ├── precedence.dora │ ├── self1.dora │ ├── stack-overflow1.dora │ └── stack-overflow2.dora ├── ops │ ├── ops-add-assign-array-intrinsic.dora │ ├── ops-add-assign-array.dora │ ├── ops-add-assign-context-var-intrinsic.dora │ ├── ops-add-assign-context-var.dora │ ├── ops-add-assign-field-intrinsic.dora │ ├── ops-add-assign-field.dora │ ├── ops-add-assign-global-intrinsic.dora │ ├── ops-add-assign-global-path-intrinsic.dora │ ├── ops-add-assign-global-path.dora │ ├── ops-add-assign-global.dora │ ├── ops-add-assign-local-var-intrinsic.dora │ ├── ops-add-assign-local-var.dora │ ├── ops-add-assign-outer-context-var-intrinsic.dora │ ├── ops-add-assign-outer-context-var.dora │ ├── ops-add1.dora │ ├── ops-arith-shr1.dora │ ├── ops-bitand-array-intrinsic.dora │ ├── ops-bitand-array.dora │ ├── ops-bitand-assign-context-var-intrinsic.dora │ ├── ops-bitand-assign-context-var.dora │ ├── ops-bitand-assign-field-intrinsic.dora │ ├── ops-bitand-assign-field.dora │ ├── ops-bitand-assign-global-intrinsic.dora │ ├── ops-bitand-assign-global.dora │ ├── ops-bitand-assign-local-var-intrinsic.dora │ ├── ops-bitand-assign-local-var.dora │ ├── ops-bitand1.dora │ ├── ops-bitor-array-intrinsic.dora │ ├── ops-bitor-array.dora │ ├── ops-bitor-assign-context-var-intrinsic.dora │ ├── ops-bitor-assign-context-var.dora │ ├── ops-bitor-assign-field-intrinsic.dora │ ├── ops-bitor-assign-field.dora │ ├── ops-bitor-assign-global-intrinsic.dora │ ├── ops-bitor-assign-global.dora │ ├── ops-bitor-assign-local-var-intrinsic.dora │ ├── ops-bitor-assign-local-var.dora │ ├── ops-bitor1.dora │ ├── ops-bitxor-array-intrinsic.dora │ ├── ops-bitxor-array.dora │ ├── ops-bitxor-assign-context-var-intrinsic.dora │ ├── ops-bitxor-assign-context-var.dora │ ├── ops-bitxor-assign-field-intrinsic.dora │ ├── ops-bitxor-assign-field.dora │ ├── ops-bitxor-assign-global-intrinsic.dora │ ├── ops-bitxor-assign-global.dora │ ├── ops-bitxor-assign-local-var-intrinsic.dora │ ├── ops-bitxor-assign-local-var.dora │ ├── ops-bitxor1.dora │ ├── ops-div-array-intrinsic.dora │ ├── ops-div-array.dora │ ├── ops-div-assign-context-var-intrinsic.dora │ ├── ops-div-assign-context-var.dora │ ├── ops-div-assign-field-intrinsic.dora │ ├── ops-div-assign-field.dora │ ├── ops-div-assign-global-intrinsic.dora │ ├── ops-div-assign-global.dora │ ├── ops-div-assign-local-var-intrinsic.dora │ ├── ops-div-assign-local-var.dora │ ├── ops-div1.dora │ ├── ops-index-get1.dora │ ├── ops-index-set1.dora │ ├── ops-logical-shr1.dora │ ├── ops-mod-array-intrinsic.dora │ ├── ops-mod-array.dora │ ├── ops-mod-assign-context-var-intrinsic.dora │ ├── ops-mod-assign-context-var.dora │ ├── ops-mod-assign-field-intrinsic.dora │ ├── ops-mod-assign-field.dora │ ├── ops-mod-assign-global-intrinsic.dora │ ├── ops-mod-assign-global.dora │ ├── ops-mod-assign-local-var-intrinsic.dora │ ├── ops-mod-assign-local-var.dora │ ├── ops-mod1.dora │ ├── ops-mul-array-intrinsic.dora │ ├── ops-mul-array.dora │ ├── ops-mul-assign-context-var-intrinsic.dora │ ├── ops-mul-assign-context-var.dora │ ├── ops-mul-assign-field-intrinsic.dora │ ├── ops-mul-assign-field.dora │ ├── ops-mul-assign-global-intrinsic.dora │ ├── ops-mul-assign-global.dora │ ├── ops-mul-assign-local-var-intrinsic.dora │ ├── ops-mul-assign-local-var.dora │ ├── ops-mul-assign-outer-context-var-intrinsic.dora │ ├── ops-mul-assign-outer-context-var.dora │ ├── ops-mul1.dora │ ├── ops-neg1.dora │ ├── ops-not1.dora │ ├── ops-sar-array-intrinsic.dora │ ├── ops-sar-array.dora │ ├── ops-sar-assign-context-var-intrinsic.dora │ ├── ops-sar-assign-context-var.dora │ ├── ops-sar-assign-field-intrinsic.dora │ ├── ops-sar-assign-field.dora │ ├── ops-sar-assign-global-intrinsic.dora │ ├── ops-sar-assign-global.dora │ ├── ops-sar-assign-local-var-intrinsic.dora │ ├── ops-sar-assign-local-var.dora │ ├── ops-sar-assign-outer-context-var-intrinsic.dora │ ├── ops-sar-assign-outer-context-var.dora │ ├── ops-shl-array-intrinsic.dora │ ├── ops-shl-array.dora │ ├── ops-shl-assign-context-var-intrinsic.dora │ ├── ops-shl-assign-context-var.dora │ ├── ops-shl-assign-field-intrinsic.dora │ ├── ops-shl-assign-field.dora │ ├── ops-shl-assign-global-intrinsic.dora │ ├── ops-shl-assign-global.dora │ ├── ops-shl-assign-local-var-intrinsic.dora │ ├── ops-shl-assign-local-var.dora │ ├── ops-shl-assign-outer-context-var-intrinsic.dora │ ├── ops-shl-assign-outer-context-var.dora │ ├── ops-shl1.dora │ ├── ops-shr-array-intrinsic.dora │ ├── ops-shr-array.dora │ ├── ops-shr-assign-context-var-intrinsic.dora │ ├── ops-shr-assign-context-var.dora │ ├── ops-shr-assign-field-intrinsic.dora │ ├── ops-shr-assign-field.dora │ ├── ops-shr-assign-global-intrinsic.dora │ ├── ops-shr-assign-global.dora │ ├── ops-shr-assign-local-var-intrinsic.dora │ ├── ops-shr-assign-local-var.dora │ ├── ops-shr-assign-outer-context-var-intrinsic.dora │ ├── ops-shr-assign-outer-context-var.dora │ ├── ops-sub-array-intrinsic.dora │ ├── ops-sub-array.dora │ ├── ops-sub-assign-context-var-intrinsic.dora │ ├── ops-sub-assign-context-var.dora │ ├── ops-sub-assign-field-intrinsic.dora │ ├── ops-sub-assign-field.dora │ ├── ops-sub-assign-global-intrinsic.dora │ ├── ops-sub-assign-global.dora │ ├── ops-sub-assign-local-var-assign.dora │ ├── ops-sub-assign-local-var.dora │ ├── ops-sub-assign-outer-context-var-intrinsic.dora │ ├── ops-sub-assign-outer-context-var.dora │ └── ops-sub1.dora ├── opt │ └── load-elimination.dora ├── stacktrace │ ├── print-stack-trace1.dora │ └── print-stack-trace2.dora ├── stdlib │ ├── abort1.dora │ ├── arg1.dora │ ├── array-join1.dora │ ├── bitset1.dora │ ├── bitvec-intersect1.dora │ ├── bitvec-intersect2.dora │ ├── bitvec-union1.dora │ ├── bitvec1.dora │ ├── char-encode-utf8.dora │ ├── char-len-utf8.dora │ ├── cmp-char.dora │ ├── cmp-float32.dora │ ├── cmp-float64.dora │ ├── cmp-int32.dora │ ├── cmp-int64.dora │ ├── exit0.dora │ ├── exit1.dora │ ├── exit2.dora │ ├── fatal1.dora │ ├── fatal2.dora │ ├── hashmap-clone1.dora │ ├── hashmap-retainif1.dora │ ├── hashmap1.dora │ ├── hashmap2.dora │ ├── hashmap3.dora │ ├── hashmap4.dora │ ├── hashset1.dora │ ├── hashset2.dora │ ├── hashset3.dora │ ├── hex1.dora │ ├── int-alias.dora │ ├── int32.dora │ ├── iterator-collect-map.dora │ ├── iterator-collect.dora │ ├── iterator-count1.dora │ ├── iterator-enumerate.dora │ ├── iterator-fold.dora │ ├── iterator-join.dora │ ├── iterator-map.dora │ ├── iterator-reduce.dora │ ├── limit1.dora │ ├── num-as.dora │ ├── num-hash.dora │ ├── option-getOrDefault.dora │ ├── option-getOrZero.dora │ ├── option-or.dora │ ├── option1.dora │ ├── option2.dora │ ├── ordering1.dora │ ├── parse1.dora │ ├── queue1.dora │ ├── queue2.dora │ ├── rand1.dora │ ├── range1.dora │ ├── result-contains.dora │ ├── result-equals.dora │ ├── result-getErrOrDefault.dora │ ├── result-getErrOrZero.dora │ ├── result-getOrDefault.dora │ ├── result-getOrZero.dora │ ├── result-isErr.dora │ ├── result-isOk.dora │ ├── result-or.dora │ ├── sleep1.dora │ ├── stringbuffer-append.dora │ ├── unreachable1.dora │ ├── vec-join1.dora │ ├── vec-remove-at.dora │ ├── vec-sort.dora │ └── vec1.dora ├── string │ ├── concat1.dora │ ├── string-clone.dora │ ├── string-comparisons.dora │ ├── string-concat.dora │ ├── string-contains.dora │ ├── string-endsWith.dora │ ├── string-from-bytes.dora │ ├── string-gc.dora │ ├── string-getByte.dora │ ├── string-indexOfFirst.dora │ ├── string-length.dora │ ├── string-main.dora │ ├── string-startsWith.dora │ ├── string-toString.dora │ ├── string-utf8-literals.dora │ ├── stringable.dora │ ├── template1.dora │ ├── template2.dora │ └── template3.dora ├── struct │ ├── struct-argument.dora │ ├── struct-array1.dora │ ├── struct-array2.dora │ ├── struct-array3.dora │ ├── struct-array4.dora │ ├── struct-array5.dora │ ├── struct-barrier.dora │ ├── struct-class1.dora │ ├── struct-class2.dora │ ├── struct-double.dora │ ├── struct-float.dora │ ├── struct-gc1.dora │ ├── struct-global-assign1.dora │ ├── struct-global-assign2.dora │ ├── struct-load.dora │ ├── struct-local-assign.dora │ ├── struct-move.dora │ ├── struct-named-pattern1.dora │ ├── struct-named-pattern2.dora │ ├── struct-nested1.dora │ ├── struct-new.dora │ ├── struct-parameter.dora │ ├── struct-plus1.dora │ ├── struct-ref1.dora │ ├── struct-ref2.dora │ ├── struct-return-direct1.dora │ ├── struct-return-static1.dora │ ├── struct-template1.dora │ └── struct-template2.dora ├── swiper │ ├── full1.dora │ ├── large-array1.dora │ ├── large1.dora │ ├── large2.dora │ ├── large3.dora │ ├── large4.dora │ ├── large5.dora │ ├── large6.dora │ ├── largeobject.dora │ ├── marking1.dora │ ├── marking2.dora │ ├── marking3.dora │ ├── minor1.dora │ ├── minor2.dora │ ├── minor3.dora │ ├── objarray1.dora │ ├── objarray2.dora │ ├── objarray3.dora │ ├── objarray4.dora │ ├── old2young1.dora │ ├── old2young2.dora │ ├── old2young3.dora │ ├── old2young4.dora │ ├── perm1.dora │ ├── promote1.dora │ ├── promote2.dora │ ├── promote3.dora │ ├── promote4.dora │ ├── promote5.dora │ └── promote6.dora ├── thread │ ├── allocate1.dora │ ├── allocate2.dora │ ├── allocate3.dora │ ├── join1.dora │ ├── join2-copy.dora │ ├── join2-swiper-compact.dora │ ├── join2-swiper-minor.dora │ ├── join3.dora │ ├── mutex-lock.dora │ ├── native1.dora │ ├── spawn1.dora │ ├── thread-condition1.dora │ ├── thread-current-main.dora │ ├── thread-mutex1.dora │ └── thread-unlock-fail.dora ├── trait │ ├── super-trait-operator-overloading1.dora │ ├── super-trait-regular-call.dora │ ├── trait-assoc-class-named.dora │ ├── trait-assoc-class-unnamed.dora │ ├── trait-assoc-struct-named.dora │ ├── trait-assoc-struct-unnamed.dora │ ├── trait-default-collect1.dora │ ├── trait-default-collect2.dora │ ├── trait-default-count.dora │ ├── trait-default-enumerate.dora │ ├── trait-default-filter.dora │ ├── trait-default-join.dora │ ├── trait-default-map.dora │ ├── trait-default-rev.dora │ ├── trait-default1.dora │ ├── trait-default2.dora │ ├── trait-default3.dora │ ├── trait-extension1.dora │ ├── trait-generic-static1.dora │ ├── trait-generic-static2.dora │ ├── trait-generic-static3.dora │ ├── trait-impl1.dora │ ├── trait-object-field1.dora │ ├── trait-object-generic-ty1.dora │ ├── trait-object-ignore1.dora │ ├── trait-object-in-array.dora │ ├── trait-object-in-vec.dora │ ├── trait-object-iterator.dora │ ├── trait-object1.dora │ ├── trait-object2.dora │ ├── trait-object3.dora │ └── trait-super-assoc.dora ├── tuple │ ├── tuple-array1.dora │ ├── tuple-array2.dora │ ├── tuple-array3.dora │ ├── tuple-array4.dora │ ├── tuple-array5.dora │ ├── tuple-array6.dora │ ├── tuple-array7.dora │ ├── tuple-array8.dora │ ├── tuple-barrier.dora │ ├── tuple-class1.dora │ ├── tuple-class2.dora │ ├── tuple-destruct1.dora │ ├── tuple-double.dora │ ├── tuple-extension1.dora │ ├── tuple-float.dora │ ├── tuple-gc1.dora │ ├── tuple-global-assign1.dora │ ├── tuple-global-assign2.dora │ ├── tuple-global-gc1.dora │ ├── tuple-impl1.dora │ ├── tuple-int32.dora │ ├── tuple-int64.dora │ ├── tuple-local-assign.dora │ ├── tuple-mixed.dora │ ├── tuple-nested1.dora │ ├── tuple-nested2.dora │ ├── tuple-nested3.dora │ ├── tuple-parameter.dora │ ├── tuple-ref.dora │ ├── tuple-return-direct1.dora │ ├── tuple-return-value.dora │ ├── tuple-struct1.dora │ ├── tuple-template1.dora │ └── tuple-template2.dora ├── unit │ ├── unit-array1.dora │ ├── unit-array2.dora │ ├── unit-array3.dora │ ├── unit-array4.dora │ ├── unit-array5.dora │ ├── unit-class1.dora │ ├── unit-for1.dora │ ├── unit-for2.dora │ ├── unit-global.dora │ ├── unit-param.dora │ ├── unit-struct1.dora │ ├── unit-template1.dora │ ├── unit-var.dora │ └── unit-vec1.dora ├── vec │ ├── vec-enumerate2.dora │ ├── vec-equals.dora │ ├── vec-field1.dora │ ├── vec-field2.dora │ ├── vec-for1.dora │ ├── vec-for2.dora │ ├── vec-insertAt.dora │ ├── vec-lambda.dora │ ├── vec-removeif.dora │ ├── vec-struct1.dora │ ├── vec-toString.dora │ ├── vec-tuple1.dora │ ├── vec1.dora │ ├── vec2.dora │ └── vec3.dora └── whiteboard │ ├── fizzbuzz.dora │ ├── fizzbuzz.stdout │ ├── sieve.dora │ └── sieve.stdout └── tools ├── build ├── build-arm64 ├── build.ps1 ├── bytecode-gen.rb ├── fuzz-runner.rb ├── gc-bench ├── run-with-boots ├── tcp-server.py ├── test ├── test-3stage-bootstrap ├── test-3stage-bootstrap-mac-x64 ├── test-boots ├── test-boots-mac-x64 ├── test-gc ├── test-mac-x64 ├── test-release ├── test-release.ps1 ├── test.ps1 └── tester.rb /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | *.swp 3 | *.class 4 | /program.s 5 | /program.o 6 | /program 7 | tests/io/test123.txt 8 | tests/io/write-as-string1.txt 9 | tests/io/write-as-bytes1.txt 10 | ssa.html 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/*.un~": true, 4 | "experiments/raise/target/**": true, 5 | "lib/dora-parser/target/**": true, 6 | "target/**": true 7 | }, 8 | "files.watcherExclude": { 9 | "**/target/**": true 10 | }, 11 | "editor.formatOnSave": true 12 | } -------------------------------------------------------------------------------- /bench/binarytrees/.gitignore: -------------------------------------------------------------------------------- 1 | binarytrees 2 | -------------------------------------------------------------------------------- /bench/binarytrees/README.md: -------------------------------------------------------------------------------- 1 | Notebook Fedora 2 | =============== 3 | * java (open jdk 8): 8.3s 4 | * perl: 739s 5 | -------------------------------------------------------------------------------- /bench/gc/alloc_garbage.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut i = 0; 3 | 4 | while i < 10000000 { 5 | Foo(i); 6 | 7 | i = i + 1; 8 | } 9 | } 10 | 11 | class Foo(let a: Int) 12 | -------------------------------------------------------------------------------- /bench/gc/alloc_linked_list.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut list: Foo = nil; 3 | let mut i = 0; 4 | 5 | while i < 10000000 { 6 | if i % 5 != 0 { 7 | list = Foo(i, list); 8 | } 9 | 10 | i = i + 1; 11 | } 12 | } 13 | 14 | class Foo(let a: Int, let next: Foo) 15 | -------------------------------------------------------------------------------- /bench/mandelbrot/mandelbrot_out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinfuehr/dora/f27f68a8ce9dd1e4360b882efe245b71f4e1e2b3/bench/mandelbrot/mandelbrot_out -------------------------------------------------------------------------------- /bench/nbody/output.txt: -------------------------------------------------------------------------------- 1 | -0.169075164 2 | -0.169059907 3 | -------------------------------------------------------------------------------- /dora-asm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dora-asm" 3 | version = "0.0.1" 4 | authors = ["Dominik Inführ "] 5 | edition = "2021" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | byteorder = "1.3.*" 11 | -------------------------------------------------------------------------------- /dora-bytecode/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dora-bytecode" 3 | version = "0.0.2" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | num_enum = "*" 10 | bincode = "2.0.0-rc.3" -------------------------------------------------------------------------------- /dora-bytecode/src/serializer.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinfuehr/dora/f27f68a8ce9dd1e4360b882efe245b71f4e1e2b3/dora-bytecode/src/serializer.rs -------------------------------------------------------------------------------- /dora-frontend/src/error.rs: -------------------------------------------------------------------------------- 1 | pub mod diag; 2 | pub mod msg; 3 | -------------------------------------------------------------------------------- /dora-frontend/src/sema/tuples.rs: -------------------------------------------------------------------------------- 1 | use crate::sema::Sema; 2 | use crate::ty::{SourceType, SourceTypeArray}; 3 | 4 | pub fn create_tuple(_sa: &Sema, args: Vec) -> SourceType { 5 | SourceType::Tuple(SourceTypeArray::with(args)) 6 | } 7 | -------------------------------------------------------------------------------- /dora-parser/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /dora-runtime/src/disassembler.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "default")] 2 | pub use self::capstone::{disassemble, supported}; 3 | 4 | #[cfg(not(feature = "default"))] 5 | pub use self::none::{disassemble, supported}; 6 | 7 | #[cfg(feature = "default")] 8 | mod capstone; 9 | 10 | #[cfg(not(feature = "default"))] 11 | mod none; 12 | -------------------------------------------------------------------------------- /dora-runtime/src/disassembler/none.rs: -------------------------------------------------------------------------------- 1 | use crate::vm::{Code, VM}; 2 | use dora_bytecode::{BytecodeTypeArray, FunctionId}; 3 | 4 | pub fn supported() -> bool { 5 | false 6 | } 7 | 8 | pub fn disassemble(_vm: &VM, _fct_id: FunctionId, _type_params: &BytecodeTypeArray, _code: &Code) { 9 | unreachable!(); 10 | } 11 | -------------------------------------------------------------------------------- /dora-runtime/src/gc/allocator.rs: -------------------------------------------------------------------------------- 1 | use crate::gc::Region; 2 | use crate::vm::VM; 3 | 4 | pub trait GenerationAllocator { 5 | fn allocate(&self, vm: &VM, min_size: usize, max_size: usize) -> Option; 6 | fn free(&self, region: Region); 7 | } 8 | -------------------------------------------------------------------------------- /dora-runtime/src/os.rs: -------------------------------------------------------------------------------- 1 | pub use self::allocator::*; 2 | pub use self::page::*; 3 | 4 | pub mod allocator; 5 | pub mod page; 6 | pub mod perf; 7 | -------------------------------------------------------------------------------- /dora-sema-fuzzer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dora-sema-fuzzer" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | dora-frontend = { path = "../dora-frontend", version = "0.0.2" } 10 | afl = "*" 11 | -------------------------------------------------------------------------------- /dora-token-fuzzer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dora-token-fuzzer" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /dora-token-fuzzer/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | fn main() { 4 | let _file = fs::read_to_string(&"tests/hello-world.dora").expect("failed to read"); 5 | println!("Hello, world!"); 6 | } 7 | -------------------------------------------------------------------------------- /dora/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /dora/src/driver.rs: -------------------------------------------------------------------------------- 1 | pub use self::start::*; 2 | 3 | pub mod flags; 4 | pub mod start; 5 | -------------------------------------------------------------------------------- /dora/src/main.rs: -------------------------------------------------------------------------------- 1 | mod driver; 2 | 3 | fn main() { 4 | std::process::exit(driver::start()); 5 | } 6 | -------------------------------------------------------------------------------- /editors/code/.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | .vscode-test/ 4 | *.vsix 5 | -------------------------------------------------------------------------------- /editors/code/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /editors/code/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | src/** 5 | .gitignore 6 | **/tsconfig.json 7 | **/.eslintrc.json 8 | **/*.map 9 | **/*.ts 10 | -------------------------------------------------------------------------------- /editors/code/README.md: -------------------------------------------------------------------------------- 1 | # vscode-dora README 2 | 3 | This extension provides syntax highlighting for Dora. 4 | 5 | **Enjoy!** 6 | -------------------------------------------------------------------------------- /pkgs/boots/dora-project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "boots", 3 | "main": "boots.dora", 4 | "packages": [] 5 | } -------------------------------------------------------------------------------- /rust-toolchain: -------------------------------------------------------------------------------- 1 | stable 2 | -------------------------------------------------------------------------------- /tests/alias/alias-int1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | expect(6); 3 | X().expect(8); 4 | } 5 | 6 | fn expect(value: Int) { 7 | assert(value == 6); 8 | } 9 | 10 | class X 11 | 12 | impl X { 13 | fn expect(value: Int) { 14 | assert(value == 8); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/array/array-compare-panic1.dora: -------------------------------------------------------------------------------- 1 | //= error 2 | 3 | fn main() { 4 | let a = Array[Int32]::new(1i32, 2i32, 3i32, 3i32, 4i32, 5i32, 4i32, 5i32, 4i32, 3i32, 3i32); 5 | 6 | assert(Array[Int32]::compare(a, 0i64, a, 0i64, 12i64)); 7 | } 8 | -------------------------------------------------------------------------------- /tests/array/array-compare-panic2.dora: -------------------------------------------------------------------------------- 1 | //= error 2 | 3 | fn main() { 4 | let a = Array[Int32]::new(1i32, 2i32, 3i32, 3i32, 4i32, 5i32, 4i32, 5i32, 4i32, 3i32, 3i32); 5 | let e = Array[Int32]::new(); 6 | 7 | assert(Array[Int32]::compare(a, 0i64, e, 0i64, 2i64)); 8 | } 9 | -------------------------------------------------------------------------------- /tests/array/array-compare-panic3.dora: -------------------------------------------------------------------------------- 1 | //= error 2 | 3 | fn main() { 4 | let a = Array[Int32]::new(1i32, 2i32, 3i32, 3i32, 4i32, 5i32, 4i32, 5i32, 4i32, 3i32, 3i32); 5 | let e = Array[Int32]::new(); 6 | 7 | assert(Array[Int32]::compare(e, 0i64, a, 0i64, 2i64)); 8 | } 9 | -------------------------------------------------------------------------------- /tests/array/array-compare-panic4.dora: -------------------------------------------------------------------------------- 1 | //= error 2 | 3 | fn main() { 4 | let e = Array[Int32]::new(); 5 | 6 | assert(Array[Int32]::compare(e, 0i64, e, 0i64, 2i64)); 7 | } 8 | -------------------------------------------------------------------------------- /tests/array/array-enumerate1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "0 -> 2\n1 -> 4\n2 -> 8\n" 2 | 3 | fn main() { 4 | for idx_and_value in Array[Int32]::new(2i32, 4i32, 8i32).enumerate() { 5 | let (idx, value) = idx_and_value; 6 | println("${idx} -> ${value}"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/array/array-field2.dora: -------------------------------------------------------------------------------- 1 | class Foo { array: Array[Int32] } 2 | 3 | impl Foo { 4 | static fn new(): Foo { 5 | Foo(Array[Int32]::new(1i32, 2i32, 3i32)) 6 | } 7 | } 8 | 9 | fn main() { 10 | let foo = Foo::new(); 11 | assert(foo.array(0i64) == 1i32); 12 | } 13 | -------------------------------------------------------------------------------- /tests/array/array-gc.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Array[Foo]::fill(5i64, Foo(17i32)); 3 | x(0i64) = Foo(1i32); 4 | x(4i64) = Foo(2i32); 5 | std::forceCollect(); 6 | assert(x(0i64).x == 1i32); 7 | assert(x(4i64).x == 2i32); 8 | } 9 | 10 | class Foo { x: Int32 } 11 | -------------------------------------------------------------------------------- /tests/array/array-list1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Array[Int32]::new(1i32, 2i32, 3i32); 3 | assert(x.size() == 3i64); 4 | assert(x(2i64) == 3i32); 5 | assert(x(1i64) == 2i32); 6 | assert(x(0i64) == 1i32); 7 | } 8 | -------------------------------------------------------------------------------- /tests/array/array-rest1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(number_args(1i32, 2i32) == 2i64); 3 | assert(number_args(7i32) == 1i64); 4 | assert(number_args() == 0i64); 5 | assert(number_args(1i32, 2i32, 3i32, 4i32, 5i32) == 5i64); 6 | } 7 | 8 | fn number_args(x: Int32...): Int64 { 9 | x.size() 10 | } 11 | -------------------------------------------------------------------------------- /tests/array/array-toString.dora: -------------------------------------------------------------------------------- 1 | use std::string::Stringable; 2 | 3 | fn main() { 4 | assert(Array[Int32]::new().toString() == "Array()"); 5 | assert(Array[Int32]::new(1i32).toString() == "Array(1)"); 6 | assert(Array[Int32]::new(1i32, 2i32, 3i32).toString() == "Array(1, 2, 3)"); 7 | } 8 | -------------------------------------------------------------------------------- /tests/array/array1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | foo(Array[Int32]::new()); 3 | } 4 | 5 | fn foo(a: Array[Int32]) {} 6 | -------------------------------------------------------------------------------- /tests/array/array10.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | //= stderr "array index out of bounds\n main (tests/array/array10.dora:6:3)\n" 3 | 4 | fn main() { 5 | let array = Array[Int32]::new(); 6 | array(-1i64); 7 | } 8 | -------------------------------------------------------------------------------- /tests/array/array13.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Array[Int32]::zero(100i64); 3 | assert(x.size() == 100i64); 4 | assert(x(0i64) == 0i32); 5 | assert(x(99i64) == 0i32); 6 | } 7 | -------------------------------------------------------------------------------- /tests/array/array14.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Array[String]::fill(1i64, ""); 3 | x(0i64) = "a" + "b"; 4 | } 5 | -------------------------------------------------------------------------------- /tests/array/array2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(0 == len(Array[Int32]::new())); 3 | } 4 | 5 | fn len(a: Array[Int32]): Int64 { a.size() } 6 | -------------------------------------------------------------------------------- /tests/array/array3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(1i64 == len(Array[Int32]::fill(1i64, 0i32))); 3 | } 4 | 5 | fn len(a: Array[Int32]): Int64 { return a.size(); } 6 | -------------------------------------------------------------------------------- /tests/array/array4.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let array = Array[Int32]::fill(20i64, 2i32); 3 | assert(2i32 == array(0i64)); 4 | } 5 | -------------------------------------------------------------------------------- /tests/array/array6.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let array = Array[Int32]::fill(5i64, 1i32); 3 | array(0i64) = 2i32; 4 | assert(array(0i64) == 2i32); 5 | assert(array(1i64) == 1i32); 6 | } 7 | -------------------------------------------------------------------------------- /tests/array/array7.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | //= stderr "array index out of bounds\n main (tests/array/array7.dora:6:3)\n" 3 | 4 | fn main() { 5 | let array = Array[Int32]::new(); 6 | array(0i64); 7 | } 8 | -------------------------------------------------------------------------------- /tests/array/array8.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | //= stderr "array index out of bounds\n main (tests/array/array8.dora:6:3)\n" 3 | 4 | fn main() { 5 | let array = Array[Int32]::zero(0i64); 6 | array(0i64) = 10i32; 7 | } 8 | -------------------------------------------------------------------------------- /tests/array/array9.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | //= stderr "array index out of bounds\n main (tests/array/array9.dora:6:3)\n" 3 | 4 | fn main() { 5 | let array = Array[Int32]::new(); 6 | array(-1i64) = 10i32; 7 | } 8 | -------------------------------------------------------------------------------- /tests/atomic/atomic-int32-compare-exchange1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = std::AtomicInt32::new(10i32); 3 | assert(value.compareExchange(12i32, 20i32) == 10i32); 4 | assert(value.get() == 10i32); 5 | assert(value.compareExchange(10i32, 15i32) == 10i32); 6 | assert(value.get() == 15i32); 7 | } 8 | -------------------------------------------------------------------------------- /tests/atomic/atomic-int32-exchange1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = std::AtomicInt32::new(10i32); 3 | assert(value.exchange(20i32) == 10i32); 4 | assert(value.get() == 20i32); 5 | } 6 | -------------------------------------------------------------------------------- /tests/atomic/atomic-int32-fetch-add1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = std::AtomicInt32::new(10i32); 3 | assert(value.fetchAdd(2i32) == 10i32); 4 | assert(value.fetchAdd(5i32) == 12i32); 5 | assert(value.get() == 17i32); 6 | } 7 | -------------------------------------------------------------------------------- /tests/atomic/atomic-int32-get1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = std::AtomicInt32::new(10i32); 3 | assert(value.get() == 10i32); 4 | value.set(20i32); 5 | assert(value.get() == 20i32); 6 | } 7 | -------------------------------------------------------------------------------- /tests/atomic/atomic-int64-compare-exchange1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = std::AtomicInt64::new(10i64); 3 | assert(value.compareExchange(12i64, 20i64) == 10i64); 4 | assert(value.get() == 10i64); 5 | assert(value.compareExchange(10i64, 15i64) == 10i64); 6 | assert(value.get() == 15i64); 7 | } 8 | -------------------------------------------------------------------------------- /tests/atomic/atomic-int64-exchange1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = std::AtomicInt64::new(10i64); 3 | assert(value.exchange(20i64) == 10i64); 4 | assert(value.get() == 20i64); 5 | } 6 | -------------------------------------------------------------------------------- /tests/atomic/atomic-int64-fetch-add1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = std::AtomicInt64::new(10i64); 3 | assert(value.fetchAdd(2i64) == 10i64); 4 | assert(value.fetchAdd(5i64) == 12i64); 5 | assert(value.get() == 17i64); 6 | } 7 | -------------------------------------------------------------------------------- /tests/atomic/atomic-int64-get1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = std::AtomicInt64::new(10i64); 3 | assert(value.get() == 10i64); 4 | value.set(20i64); 5 | assert(value.get() == 20i64); 6 | } 7 | -------------------------------------------------------------------------------- /tests/bench/binarytrees-mt1.dora: -------------------------------------------------------------------------------- 1 | //= file bench/binarytrees/binarytrees-mt.dora 2 | //= args 14 4 3 | //= vm-args "--max-heap-size=256M" 4 | //= stdout file -------------------------------------------------------------------------------- /tests/bench/binarytrees1.dora: -------------------------------------------------------------------------------- 1 | //= file bench/binarytrees/binarytrees.dora 2 | //= args 9 3 | //= stdout file -------------------------------------------------------------------------------- /tests/bench/binarytrees1.stdout: -------------------------------------------------------------------------------- 1 | stretch tree of depth 10 check: 2047 2 | 512 trees of depth 4 check: 15872 3 | 128 trees of depth 6 check: 16256 4 | 32 trees of depth 8 check: 16352 5 | long lived tree of depth 9 check: 1023 6 | -------------------------------------------------------------------------------- /tests/bench/binarytrees2.dora: -------------------------------------------------------------------------------- 1 | //= file bench/binarytrees/binarytrees.dora 2 | //= args 6 3 | //= vm-args --gc-stress 4 | //= stdout file -------------------------------------------------------------------------------- /tests/bench/binarytrees2.stdout: -------------------------------------------------------------------------------- 1 | stretch tree of depth 7 check: 255 2 | 64 trees of depth 4 check: 1984 3 | 16 trees of depth 6 check: 2032 4 | long lived tree of depth 6 check: 127 5 | -------------------------------------------------------------------------------- /tests/bench/binarytrees3.dora: -------------------------------------------------------------------------------- 1 | //= file bench/binarytrees/binarytrees.dora 2 | //= args 6 3 | //= vm-args --gc=copy 4 | //= stdout file -------------------------------------------------------------------------------- /tests/bench/binarytrees3.stdout: -------------------------------------------------------------------------------- 1 | stretch tree of depth 7 check: 255 2 | 64 trees of depth 4 check: 1984 3 | 16 trees of depth 6 check: 2032 4 | long lived tree of depth 6 check: 127 5 | -------------------------------------------------------------------------------- /tests/bench/binarytrees4.dora: -------------------------------------------------------------------------------- 1 | //= file bench/binarytrees/binarytrees.dora 2 | //= args 6 3 | //= vm-args --gc=copy --gc-stress 4 | //= stdout file -------------------------------------------------------------------------------- /tests/bench/binarytrees4.stdout: -------------------------------------------------------------------------------- 1 | stretch tree of depth 7 check: 255 2 | 64 trees of depth 4 check: 1984 3 | 16 trees of depth 6 check: 2032 4 | long lived tree of depth 6 check: 127 5 | -------------------------------------------------------------------------------- /tests/bench/binarytrees5.dora: -------------------------------------------------------------------------------- 1 | //= file bench/binarytrees/binarytrees.dora 2 | //= args 6 3 | //= vm-args --gc=zero 4 | //= stdout file -------------------------------------------------------------------------------- /tests/bench/binarytrees5.stdout: -------------------------------------------------------------------------------- 1 | stretch tree of depth 7 check: 255 2 | 64 trees of depth 4 check: 1984 3 | 16 trees of depth 6 check: 2032 4 | long lived tree of depth 6 check: 127 5 | -------------------------------------------------------------------------------- /tests/bench/binarytrees5stress.dora: -------------------------------------------------------------------------------- 1 | //= file bench/binarytrees/binarytrees.dora 2 | //= args 6 3 | //= vm-args --gc=copy --gc-stress --disable-tlab 4 | //= stdout file -------------------------------------------------------------------------------- /tests/bench/binarytrees5stress.stdout: -------------------------------------------------------------------------------- 1 | stretch tree of depth 7 check: 255 2 | 64 trees of depth 4 check: 1984 3 | 16 trees of depth 6 check: 2032 4 | long lived tree of depth 6 check: 127 5 | -------------------------------------------------------------------------------- /tests/bench/binarytrees6.dora: -------------------------------------------------------------------------------- 1 | //= file bench/binarytrees/binarytrees.dora 2 | //= args 6 3 | //= vm-args --gc=zero 4 | //= stdout file -------------------------------------------------------------------------------- /tests/bench/binarytrees6.stdout: -------------------------------------------------------------------------------- 1 | stretch tree of depth 7 check: 255 2 | 64 trees of depth 4 check: 1984 3 | 16 trees of depth 6 check: 2032 4 | long lived tree of depth 6 check: 127 5 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux1.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 1 3 | //= stdout "0\nPfannkuchen (1) = 0\n" 4 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux2.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 2 3 | //= stdout "-1\nPfannkuchen (2) = 1\n" 4 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux3.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 3 3 | //= stdout "2\nPfannkuchen (3) = 2\n" 4 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux4.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 4 3 | //= stdout "4\nPfannkuchen (4) = 4\n" 4 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux5.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 5 3 | //= stdout "11\nPfannkuchen (5) = 7\n" 4 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux6.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 6 3 | //= stdout "49\nPfannkuchen (6) = 10\n" 4 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux7.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 7 3 | //= stdout "228\nPfannkuchen (7) = 16\n" 4 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux8.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 8 3 | //= stdout "1616\nPfannkuchen (8) = 22\n" 4 | -------------------------------------------------------------------------------- /tests/bench/fannkuchredux9.dora: -------------------------------------------------------------------------------- 1 | //= file bench/fannkuchredux/fannkuchredux.dora 2 | //= args 9 3 | //= stdout "8629\nPfannkuchen (9) = 30\n" 4 | -------------------------------------------------------------------------------- /tests/bench/gcbench1.dora: -------------------------------------------------------------------------------- 1 | //= file bench/gcbench/gcbench.dora 2 | //= args 6 3 | //= vm-args "--gc=swiper --max-heap-size=128M" -------------------------------------------------------------------------------- /tests/bench/gcold1.dora: -------------------------------------------------------------------------------- 1 | //= file bench/gcold/gcold.dora 2 | //= args 8 1 32 2 1000 3 | //= vm-args "--gc=swiper --max-heap-size=128M" 4 | -------------------------------------------------------------------------------- /tests/bench/nbody10.dora: -------------------------------------------------------------------------------- 1 | //= file bench/nbody/nbody.dora 2 | //= args 100 3 | //= stdout "-0.16907516382852447\n-0.1690507623824094\n" -------------------------------------------------------------------------------- /tests/bench/richards1.dora: -------------------------------------------------------------------------------- 1 | //= file bench/richards/richards.dora 2 | //= args 10 -------------------------------------------------------------------------------- /tests/bench/splay1.dora: -------------------------------------------------------------------------------- 1 | //= file bench/splay/splay.dora 2 | //= args 123 8000 10 3 | //= vm-args "--gc=swiper --max-heap-size=256M" 4 | -------------------------------------------------------------------------------- /tests/bench/splunc1.dora: -------------------------------------------------------------------------------- 1 | //= file bench/splunc/splunc.dora 2 | //= args 1234 100 1000 10 3 | //= vm-args "--gc=swiper --max-heap-size=128M" 4 | -------------------------------------------------------------------------------- /tests/boots/add-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1.5f32, 2.5f32); 5 | assert(x == 4f32); 6 | let x = f(100.25f32, 0.75f32); 7 | assert(x == 101.0f32); 8 | } 9 | 10 | @Optimize fn f(a: Float32, b: Float32): Float32 { a+b } 11 | -------------------------------------------------------------------------------- /tests/boots/add-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1.5, 2.5); 5 | assert(x == 4.0); 6 | let x = f(100.25, 0.75); 7 | assert(x == 101.0); 8 | } 9 | 10 | @Optimize fn f(a: Float64, b: Float64): Float64 { a+b } 11 | -------------------------------------------------------------------------------- /tests/boots/add-int32-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | let x = f(Int32::maxValue(), 1i32); 6 | } 7 | 8 | @Optimize fn f(a: Int32, b: Int32): Int32 { a+b } 9 | -------------------------------------------------------------------------------- /tests/boots/add-int32-same.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1i32); 5 | assert(x == 2i32); 6 | let x = f(100i32); 7 | assert(x == 200i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32): Int32 { a+a } 11 | -------------------------------------------------------------------------------- /tests/boots/add-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1i32, 2i32); 5 | assert(x == 3i32); 6 | let x = f(100i32, 12i32); 7 | assert(x == 112i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a+b } 11 | -------------------------------------------------------------------------------- /tests/boots/add-int64-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | let x = f(Int64::maxValue(), 1); 6 | } 7 | 8 | @Optimize fn f(a: Int64, b: Int64): Int64 { a+b } 9 | -------------------------------------------------------------------------------- /tests/boots/add-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1, 2); 5 | assert(x == 3); 6 | let x = f(100, 12); 7 | assert(x == 112); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a+b } 11 | -------------------------------------------------------------------------------- /tests/boots/and-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3i32, 2i32); 5 | assert(x == 2i32); 6 | let x = f(1i32, 2i32); 7 | assert(x == 0i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a & b } 11 | -------------------------------------------------------------------------------- /tests/boots/and-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3, 2); 5 | assert(x == 2); 6 | let x = f(1, 2); 7 | assert(x == 0); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a & b } 11 | -------------------------------------------------------------------------------- /tests/boots/array-length.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(Array[Int64]::newDefault(100)) == 100); 5 | assert(f(Array[Int64]::newDefault(47)) == 47); 6 | } 7 | 8 | @Optimize fn f(x: Array[Int64]): Int64 { x.size() } 9 | -------------------------------------------------------------------------------- /tests/boots/array-load-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[Float32]::newDefault(100); 5 | arr(47) = 12.0f32; 6 | assert(f(arr, 46) == 0.0f32); 7 | assert(f(arr, 47) == 12.0f32); 8 | assert(f(arr, 48) == 0.0f32); 9 | } 10 | 11 | @Optimize fn f(x: Array[Float32], idx: Int64): Float32 { x(idx) } 12 | -------------------------------------------------------------------------------- /tests/boots/array-load-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[Float64]::newDefault(100); 5 | arr(47) = 12.0; 6 | assert(f(arr, 46) == 0.0); 7 | assert(f(arr, 47) == 12.0); 8 | assert(f(arr, 48) == 0.0); 9 | } 10 | 11 | @Optimize fn f(x: Array[Float64], idx: Int64): Float64 { x(idx) } 12 | -------------------------------------------------------------------------------- /tests/boots/array-load-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[Int32]::newDefault(100); 5 | arr(47) = 12i32; 6 | assert(f(arr, 46) == 0i32); 7 | assert(f(arr, 47) == 12i32); 8 | assert(f(arr, 48) == 0i32); 9 | } 10 | 11 | @Optimize fn f(x: Array[Int32], idx: Int64): Int32 { x(idx) } 12 | -------------------------------------------------------------------------------- /tests/boots/array-load-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[Int64]::newDefault(100); 5 | arr(47) = 12; 6 | assert(f(arr, 46) == 0); 7 | assert(f(arr, 47) == 12); 8 | assert(f(arr, 48) == 0); 9 | } 10 | 11 | class Foo { val: Int64 } 12 | 13 | @Optimize fn f(x: Array[Int64], idx: Int64): Int64 { x(idx) } 14 | -------------------------------------------------------------------------------- /tests/boots/array-load-uint8.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[UInt8]::newDefault(100); 5 | arr(47) = 12u8; 6 | assert(f(arr, 46) == 0u8); 7 | assert(f(arr, 47) == 12u8); 8 | assert(f(arr, 48) == 0u8); 9 | } 10 | 11 | @Optimize fn f(x: Array[UInt8], idx: Int64): UInt8 { x(idx) } 12 | -------------------------------------------------------------------------------- /tests/boots/array-new1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = getfoo(10); 5 | std::forceCollect(); 6 | for idx in std::range(0, 10) { 7 | assert(foo(idx) == 0); 8 | } 9 | } 10 | 11 | @Optimize fn getfoo(length: Int64): Array[Int64] { Array[Int64]::zero(length) } 12 | -------------------------------------------------------------------------------- /tests/boots/array-new2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = getfoo(); 5 | std::forceCollect(); 6 | assert(foo.size() == 0); 7 | } 8 | 9 | @Optimize fn getfoo(): Array[Int64] { 10 | Array[Int64]::new() 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/array-store-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[Float64]::newDefault(100); 5 | f(arr, 47, 12.0); 6 | assert(arr(46) == 0.0); 7 | assert(arr(47) == 12.0); 8 | assert(arr(48) == 0.0); 9 | } 10 | 11 | @Optimize 12 | fn f(x: Array[Float64], idx: Int64, value: Float64) { 13 | x(idx) = value; 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/array-store-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[Int32]::fill(100, 1i32); 5 | f(arr, 47, 12i32); 6 | assert(arr(46) == 1i32); 7 | assert(arr(47) == 12i32); 8 | assert(arr(48) == 1i32); 9 | } 10 | 11 | @Optimize 12 | fn f(x: Array[Int32], idx: Int64, value: Int32) { 13 | x(idx) = value; 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/array-store-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[Int64]::newDefault(100); 5 | f(arr, 47, 12); 6 | assert(arr(46) == 0); 7 | assert(arr(47) == 12); 8 | assert(arr(48) == 0); 9 | } 10 | 11 | @Optimize 12 | fn f(x: Array[Int64], idx: Int64, value: Int64) { 13 | x(idx) = value; 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/array-store-uint8.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arr = Array[UInt8]::fill(100, 1u8); 5 | f(arr, 47, 12u8); 6 | assert(arr(46) == 1u8); 7 | assert(arr(47) == 12u8); 8 | assert(arr(48) == 1u8); 9 | } 10 | 11 | @Optimize 12 | fn f(x: Array[UInt8], idx: Int64, value: UInt8) { 13 | x(idx) = value; 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/assert1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | f(true); 5 | } 6 | 7 | @Optimize fn f(value: Bool) { 8 | assert(value); 9 | } 10 | -------------------------------------------------------------------------------- /tests/boots/assert2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error assert 3 | 4 | fn main() { 5 | f(false); 6 | } 7 | 8 | @Optimize fn f(value: Bool) { 9 | assert(value); 10 | } 11 | -------------------------------------------------------------------------------- /tests/boots/call-direct-intrinsic.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(add1(2, 3) == 5); 5 | assert(add2(2i32, 3i32) == 5i32); 6 | } 7 | 8 | @Optimize fn add1(a: Int64, b: Int64): Int64 { 9 | a.wrappingAdd(b) 10 | } 11 | 12 | @Optimize fn add2(a: Int32, b: Int32): Int32 { 13 | a.wrappingAdd(b) 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/call-direct-no-args.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(47); 5 | assert(f(foo) == 47); 6 | } 7 | 8 | @Optimize fn f(foo: Foo): Int64 { 9 | foo.g() 10 | } 11 | 12 | class Foo { value: Int64 } 13 | 14 | impl Foo { 15 | fn g(): Int64 { 16 | self.value 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/boots/call-lambda-noargs.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let get42 = ||: Int64 { 42 }; 5 | assert(f(get42) == 42); 6 | 7 | let get27 = ||: Int64 { 27 }; 8 | assert(f(get27) == 27); 9 | } 10 | 11 | @Optimize fn f(bar: (): Int64): Int64 { 12 | bar() 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/call-lambda-tuple1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let lambda = ||: (Int64, Int64) { 5 | (1, 2) 6 | }; 7 | let foo = f(lambda); 8 | assert(foo.0 == 1); 9 | assert(foo.1 == 2); 10 | } 11 | 12 | @Optimize fn f(lambda: (): (Int64, Int64)): (Int64, Int64) { 13 | let foo = lambda(); 14 | foo 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/call-static-enum1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = f(); 5 | assert(foo == Foo::A); 6 | } 7 | 8 | enum Foo { A, B, C } 9 | 10 | @Optimize fn f(): Foo { 11 | let foo = g(); 12 | foo 13 | } 14 | 15 | fn g(): Foo { 16 | Foo::A 17 | } 18 | -------------------------------------------------------------------------------- /tests/boots/call-static-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(2.5f32, 4i32) == 10.0f32); 5 | } 6 | 7 | @Optimize fn f(arg1: Float32, arg2: Int32): Float32 { 8 | g(arg1, arg2) 9 | } 10 | 11 | fn g(arg1: Float32, arg2: Int32): Float32 { 12 | arg1 * arg2.toFloat32() 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/call-static-int64-arg.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | f(12); 5 | } 6 | 7 | @Optimize fn f(x: Int64) { 8 | g(x); 9 | } 10 | 11 | fn g(x: Int64) { 12 | assert(x == 12); 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/call-static-int64-arg2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | f(12, 14); 5 | } 6 | 7 | @Optimize fn f(x: Int64, y: Int64) { 8 | g(y); 9 | } 10 | 11 | fn g(x: Int64) { 12 | assert(x == 14); 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/call-static-int64-return.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f() == 12); 5 | } 6 | 7 | @Optimize fn f(): Int64 { 8 | g() 9 | } 10 | 11 | fn g(): Int64 { 12 | 12 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/call-static-intrinsic.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let t = mythread(); 5 | assert(std::Thread::current() === t); 6 | } 7 | 8 | @Optimize fn mythread(): std::Thread { 9 | std::Thread::current() 10 | } 11 | -------------------------------------------------------------------------------- /tests/boots/call-static-noargs.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | f(); 5 | } 6 | 7 | @Optimize fn f() { 8 | g(); 9 | } 10 | 11 | fn g() {} 12 | -------------------------------------------------------------------------------- /tests/boots/call-static-struct-arg.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(1, 2); 5 | f(3, foo); 6 | } 7 | 8 | struct Foo(Int64, Int64) 9 | 10 | @Optimize fn f(x: Int64, foo: Foo) { 11 | g(foo); 12 | } 13 | 14 | fn g(foo: Foo) { 15 | assert(foo.0 == 1); 16 | assert(foo.1 == 2); 17 | } 18 | -------------------------------------------------------------------------------- /tests/boots/call-static-struct.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = f(); 5 | assert(foo.a == 1); 6 | assert(foo.b == 2); 7 | } 8 | 9 | struct Foo { a: Int64, b: Int64 } 10 | 11 | @Optimize fn f(): Foo { 12 | let foo = g(); 13 | foo 14 | } 15 | 16 | fn g(): Foo { 17 | Foo(a = 1, b = 2) 18 | } 19 | -------------------------------------------------------------------------------- /tests/boots/call-static-tuple-arg.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = (1, 2); 5 | f(3, foo); 6 | } 7 | 8 | @Optimize fn f(x: Int64, foo: (Int64, Int64)) { 9 | g(foo); 10 | } 11 | 12 | fn g(foo: (Int64, Int64)) { 13 | assert(foo.0 == 1); 14 | assert(foo.1 == 2); 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/call-static-tuple1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = f(); 5 | assert(foo.0 == 1); 6 | assert(foo.1 == 2); 7 | } 8 | 9 | @Optimize fn f(): (Int64, Int64) { 10 | let foo = g(); 11 | foo 12 | } 13 | 14 | fn g(): (Int64, Int64) { 15 | (1, 2) 16 | } 17 | -------------------------------------------------------------------------------- /tests/boots/class-load-enum1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(Foo(Bar::A)) == Bar::A); 5 | assert(f(Foo(Bar::B)) == Bar::B); 6 | } 7 | 8 | class Foo { bar: Bar } 9 | enum Bar { A, B, C } 10 | 11 | @Optimize fn f(x: Foo): Bar { 12 | let result = x.bar; 13 | std::forceCollect(); 14 | result 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/class-load-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(Foo(10)) == 10); 5 | assert(f(Foo(17)) == 17); 6 | } 7 | 8 | class Foo { val: Int64 } 9 | 10 | @Optimize fn f(x: Foo): Int64 { x.val } 11 | -------------------------------------------------------------------------------- /tests/boots/class-load-pointer.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(Foo(Bar(10))).val == 10); 5 | assert(f(Foo(Bar(17))).val == 17); 6 | } 7 | 8 | class Foo { bar: Bar } 9 | class Bar { val: Int64 } 10 | 11 | @Optimize fn f(x: Foo): Bar { x.bar } 12 | -------------------------------------------------------------------------------- /tests/boots/class-load-struct1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let bar = f(Foo(Bar(1, 2))); 5 | assert(bar.0 == 1); 6 | assert(bar.1 == 2); 7 | } 8 | 9 | class Foo { bar: Bar } 10 | struct Bar(Int64, Int64) 11 | 12 | @Optimize fn f(x: Foo): Bar { x.bar } 13 | -------------------------------------------------------------------------------- /tests/boots/class-load-tuple1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let bar = f(Foo((1, 2))); 5 | assert(bar.0 == 1); 6 | assert(bar.1 == 2); 7 | } 8 | 9 | class Foo { bar: (Int64, Int64) } 10 | 11 | @Optimize fn f(x: Foo): (Int64, Int64) { x.bar } 12 | -------------------------------------------------------------------------------- /tests/boots/class-new1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = getfoo(); 5 | std::forceCollect(); 6 | } 7 | 8 | class Foo 9 | 10 | @Optimize fn getfoo(): Foo { Foo() } 11 | -------------------------------------------------------------------------------- /tests/boots/class-new2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = getfoo(); 5 | std::forceCollect(); 6 | assert(foo.a == 1); 7 | assert(foo.b == 2); 8 | } 9 | 10 | class Foo { a: Int64, b: Int64 } 11 | 12 | @Optimize fn getfoo(): Foo { Foo(a = 1, b = 2) } 13 | -------------------------------------------------------------------------------- /tests/boots/class-new5.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= vm-args "--gc=copy --disable-tlab --gc-stress" 3 | 4 | fn main() { 5 | let foo = getfoo(); 6 | std::forceCollect(); 7 | } 8 | 9 | class Foo 10 | 11 | @Optimize fn getfoo(): Foo { Foo() } 12 | -------------------------------------------------------------------------------- /tests/boots/class-store-bool.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(true); 5 | f(foo, false); 6 | assert(!foo.val); 7 | 8 | let foo = Foo(false); 9 | f(foo, true); 10 | assert(foo.val); 11 | } 12 | 13 | class Foo { val: Bool } 14 | 15 | @Optimize fn f(x: Foo, y: Bool) { x.val = y; } 16 | -------------------------------------------------------------------------------- /tests/boots/class-store-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(10.0); 5 | f(foo, 12.0); 6 | assert(foo.val == 12.0); 7 | 8 | let foo = Foo(10.0); 9 | f(foo, 17.0); 10 | assert(foo.val == 17.0); 11 | } 12 | 13 | class Foo { val: Float64 } 14 | 15 | @Optimize fn f(x: Foo, y: Float64) { x.val = y; } 16 | -------------------------------------------------------------------------------- /tests/boots/class-store-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(10i32); 5 | f(foo, 12i32); 6 | assert(foo.val == 12i32); 7 | 8 | let foo = Foo(10i32); 9 | f(foo, 17i32); 10 | assert(foo.val == 17i32); 11 | } 12 | 13 | class Foo { val: Int32 } 14 | 15 | @Optimize fn f(x: Foo, y: Int32) { x.val = y; } 16 | -------------------------------------------------------------------------------- /tests/boots/class-store-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(10); 5 | f(foo, 12); 6 | assert(foo.val == 12); 7 | 8 | let foo = Foo(10); 9 | f(foo, 17); 10 | assert(foo.val == 17); 11 | } 12 | 13 | class Foo { val: Int64 } 14 | 15 | @Optimize fn f(x: Foo, y: Int64) { x.val = y; } 16 | -------------------------------------------------------------------------------- /tests/boots/class-store-uint8.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(10u8); 5 | f(foo, 12u8); 6 | assert(foo.val == 12u8); 7 | 8 | let foo = Foo(10u8); 9 | f(foo, 17u8); 10 | assert(foo.val == 17u8); 11 | } 12 | 13 | class Foo { val: UInt8 } 14 | 15 | @Optimize fn f(x: Foo, y: UInt8) { x.val = y; } 16 | -------------------------------------------------------------------------------- /tests/boots/div-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3f32, 2f32); 5 | assert(x == 1.5f32); 6 | let x = f(300.75f32, 3f32); 7 | assert(x == 100.25f32); 8 | } 9 | 10 | @Optimize fn f(a: Float32, b: Float32): Float32 { a/b } 11 | -------------------------------------------------------------------------------- /tests/boots/div-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3.0, 2.0); 5 | assert(x == 1.5); 6 | let x = f(300.75, 3.0); 7 | assert(x == 100.25); 8 | } 9 | 10 | @Optimize fn f(a: Float64, b: Float64): Float64 { a/b } 11 | -------------------------------------------------------------------------------- /tests/boots/div-int64-divby0.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error div0 3 | //= stderr "division by 0\n f (tests/boots/div-int64-divby0.dora:10:45)\n main (tests/boots/div-int64-divby0.dora:6:13)\n" 4 | 5 | fn main() { 6 | let x = f(12, 0); 7 | unreachable[()](); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a/b } 11 | -------------------------------------------------------------------------------- /tests/boots/div-int64-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | let x = f(Int64::minValue(), -1); 6 | } 7 | 8 | @Optimize fn f(a: Int64, b: Int64): Int64 { a/b } 9 | -------------------------------------------------------------------------------- /tests/boots/div-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(9, 4); 5 | assert(x == 2); 6 | let x = f(100, 4); 7 | assert(x == 25); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a/b } 11 | -------------------------------------------------------------------------------- /tests/boots/enum-eq1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(Foo::A, Foo::A)); 5 | assert(!f(Foo::A, Foo::B)); 6 | } 7 | 8 | enum Foo { A, B, C } 9 | 10 | @Optimize fn f(a: Foo, b: Foo): Bool { 11 | a == b 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/enum-ne1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(!f(Foo::A, Foo::A)); 5 | assert(f(Foo::A, Foo::B)); 6 | } 7 | 8 | enum Foo { A, B, C } 9 | 10 | @Optimize fn f(a: Foo, b: Foo): Bool { 11 | a != b 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/fail1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error 3 | 4 | fn main() { 5 | f(); 6 | } 7 | 8 | @Optimize fn f() { 9 | std::fatalError("foo"); 10 | } 11 | -------------------------------------------------------------------------------- /tests/boots/gc1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | f(); 5 | } 6 | 7 | @Optimize fn f() { 8 | std::forceCollect(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/boots/gc3.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let arg = "test"; 5 | let result = f(arg); 6 | assert(arg === result); 7 | } 8 | 9 | @Optimize fn f(a: String): String { 10 | std::forceCollect(); 11 | a 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/generic-add.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(add[Int64](2, 3) == 5); 5 | assert(add[Int32](2i32, 3i32) == 5i32); 6 | assert(add[Float64](17.0, 3.0) == 20.0); 7 | assert(add[Float32](17.0f32, 3.0f32) == 20.0f32); 8 | } 9 | 10 | @Optimize fn add[T: std::traits::Add](a: T, b: T): T { 11 | a + b 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/generic-return-id.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(id[Int64](2) == 2); 5 | assert(id[Float64](17.0) == 17.0); 6 | } 7 | 8 | @Optimize fn id[T](x: T): T { 9 | x 10 | } 11 | -------------------------------------------------------------------------------- /tests/boots/global-load-enum1-uninit.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Foo = Foo::A; 4 | 5 | fn main() { 6 | assert(getg() == Foo::A); 7 | } 8 | 9 | enum Foo { A, B, C } 10 | 11 | @Optimize fn getg(): Foo { 12 | g 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/global-load-enum1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Foo = Foo::A; 4 | 5 | fn main() { 6 | assert(g == Foo::A); 7 | assert(getg() == Foo::A); 8 | } 9 | 10 | enum Foo { A, B, C } 11 | 12 | @Optimize fn getg(): Foo { 13 | g 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/global-load-enum2-uninit.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Foo = Foo::A; 4 | 5 | fn main() { 6 | match getg() { 7 | Foo::A => {} 8 | _ => unreachable[()](), 9 | } 10 | } 11 | 12 | enum Foo { A, B, C(Int64) } 13 | 14 | @Optimize fn getg(): Foo { 15 | g 16 | } 17 | -------------------------------------------------------------------------------- /tests/boots/global-load-float32-uninit.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Float32 = 12.5f32; 4 | 5 | fn main() { 6 | assert(getg() == 12.5f32); 7 | } 8 | 9 | @Optimize fn getg(): Float32 { 10 | g 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/global-load-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Float32 = 12.5f32; 4 | 5 | fn main() { 6 | assert(g == 12.5f32); 7 | assert(getg() == 12.5f32); 8 | } 9 | 10 | @Optimize fn getg(): Float32 { 11 | g 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-load-float64-uninit.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Float64 = 12.5; 4 | 5 | fn main() { 6 | assert(getg() == 12.5); 7 | } 8 | 9 | @Optimize fn getg(): Float64 { 10 | g 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/global-load-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Float64 = 12.5; 4 | 5 | fn main() { 6 | assert(g == 12.5); 7 | assert(getg() == 12.5); 8 | } 9 | 10 | @Optimize fn getg(): Float64 { 11 | g 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-load-gc1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Int64 = { 4 | std::forceCollect(); 12 5 | }; 6 | 7 | fn main() { 8 | assert(getg(Foo(10)) == 22); 9 | } 10 | 11 | class Foo { value: Int64 } 12 | 13 | @Optimize fn getg(x: Foo): Int64 { 14 | let result = g; 15 | x.value + result 16 | } 17 | -------------------------------------------------------------------------------- /tests/boots/global-load-gc2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= vm-args --gc=copy --gc-stress 3 | 4 | let g: Int64 = { 5 | std::forceCollect(); 12 6 | }; 7 | 8 | fn main() { 9 | assert(getg(Foo(10)) == 22); 10 | } 11 | 12 | class Foo { value: Int64 } 13 | 14 | @Optimize fn getg(x: Foo): Int64 { 15 | let result = g; 16 | x.value + result 17 | } 18 | -------------------------------------------------------------------------------- /tests/boots/global-load-int32-uninit.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Int32 = 10; 4 | 5 | fn main() { 6 | assert(getg() == 10i32); 7 | } 8 | 9 | @Optimize fn getg(): Int32 { 10 | g 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/global-load-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Int32 = 10; 4 | 5 | fn main() { 6 | assert(g == 10i32); 7 | assert(getg() == 10i32); 8 | } 9 | 10 | @Optimize fn getg(): Int32 { 11 | g 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-load-int64-uninit.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Int64 = 10; 4 | 5 | fn main() { 6 | assert(getg() == 10); 7 | } 8 | 9 | @Optimize fn getg(): Int64 { 10 | g 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/global-load-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Int64 = 10; 4 | 5 | fn main() { 6 | assert(g == 10); 7 | assert(getg() == 10); 8 | } 9 | 10 | @Optimize fn getg(): Int64 { 11 | g 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-load-ptr-uninit.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Foo = Foo(10); 4 | 5 | fn main() { 6 | assert(getg().value == 10); 7 | } 8 | 9 | class Foo { value: Int64 } 10 | 11 | @Optimize fn getg(): Foo { 12 | g 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/global-load-ptr.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Foo = Foo(10); 4 | 5 | fn main() { 6 | assert(g.value == 10); 7 | assert(getg().value == 10); 8 | } 9 | 10 | class Foo { value: Int64 } 11 | 12 | @Optimize fn getg(): Foo { 13 | g 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/global-load-struct1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Foo = Foo(10, Bar(11)); 4 | 5 | fn main() { 6 | let local_g = getg(); 7 | assert(local_g.0 == 10); 8 | assert(local_g.1 .0 == 11); 9 | } 10 | 11 | struct Foo(Int64, Bar) 12 | class Bar(Int64) 13 | 14 | @Optimize fn getg(): Foo { 15 | g 16 | } 17 | -------------------------------------------------------------------------------- /tests/boots/global-load-uint8-uninit.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: UInt8 = 10u8; 4 | 5 | fn main() { 6 | assert(getg() == 10u8); 7 | } 8 | 9 | @Optimize fn getg(): UInt8 { 10 | g 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/global-load-uint8.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: UInt8 = 10u8; 4 | 5 | fn main() { 6 | assert(g == 10u8); 7 | assert(getg() == 10u8); 8 | } 9 | 10 | @Optimize fn getg(): UInt8 { 11 | g 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-store-enum1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: Foo = Foo::A; 4 | 5 | fn main() { 6 | setg(Foo::B); 7 | assert(g == Foo::B); 8 | } 9 | 10 | enum Foo { A, B, C } 11 | 12 | @Optimize fn setg(value: Foo) { 13 | g = value; 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/global-store-enum2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: Foo = Foo::A; 4 | 5 | fn main() { 6 | setg(Foo::B); 7 | match g { 8 | Foo::B => {} 9 | _ => unreachable[()](), 10 | } 11 | } 12 | 13 | enum Foo { A, B, C(Int64) } 14 | 15 | @Optimize fn setg(value: Foo) { 16 | g = value; 17 | } 18 | -------------------------------------------------------------------------------- /tests/boots/global-store-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: Float32 = 1.0f32; 4 | 5 | fn main() { 6 | setg(12.0f32); 7 | assert(g == 12.0f32); 8 | } 9 | 10 | @Optimize fn setg(value: Float32) { 11 | g = value; 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-store-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: Float64 = 1.0; 4 | 5 | fn main() { 6 | setg(12.0); 7 | assert(g == 12.0); 8 | } 9 | 10 | @Optimize fn setg(value: Float64) { 11 | g = value; 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-store-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: Int32 = 1i32; 4 | 5 | fn main() { 6 | setg(12i32); 7 | assert(g == 12i32); 8 | } 9 | 10 | @Optimize fn setg(value: Int32) { 11 | g = value; 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-store-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: Int64 = 1; 4 | 5 | fn main() { 6 | setg(12); 7 | assert(g == 12); 8 | } 9 | 10 | @Optimize fn setg(value: Int64) { 11 | g = value; 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/global-store-ptr.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: Foo = Foo(1); 4 | 5 | fn main() { 6 | setg(Foo(12)); 7 | assert(g.value == 12); 8 | } 9 | 10 | class Foo { value: Int64 } 11 | 12 | @Optimize fn setg(value: Foo) { 13 | g = value; 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/global-store-uint8.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: UInt8 = 1u8; 4 | 5 | fn main() { 6 | setg(12u8); 7 | assert(g == 12u8); 8 | } 9 | 10 | @Optimize fn setg(value: UInt8) { 11 | g = value; 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/hello-world.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | @Optimize 4 | fn main() { 5 | println("Hello World!"); 6 | } 7 | -------------------------------------------------------------------------------- /tests/boots/hello.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | f(); 5 | assert(g() == 17i32); 6 | } 7 | 8 | @Optimize fn f() {} 9 | @Optimize fn g(): Int32 { 17i32 } 10 | -------------------------------------------------------------------------------- /tests/boots/if-phi-critical.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(true) == 20); 5 | assert(f(false) == 10); 6 | } 7 | 8 | @Optimize fn f(x: Bool): Int64 { 9 | let mut result = 10; 10 | if x { 11 | result = 20 12 | } 13 | result 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/if-phi-return-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(myf(true) == 10.5f32); 5 | assert(myf(false) == 20.75f32); 6 | } 7 | 8 | @Optimize fn myf(x: Bool): Float32 { 9 | if x { 10 | 10.5f32 11 | } else { 12 | 20.75f32 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/if-phi-return-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(myf(true) == 10.5); 5 | assert(myf(false) == 20.75); 6 | } 7 | 8 | @Optimize fn myf(x: Bool): Float64 { 9 | if x { 10 | 10.5 11 | } else { 12 | 20.75 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/if-phi-return-int32-2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(true, 3) == 30); 5 | assert(f(false, 2) == 40); 6 | } 7 | 8 | @Optimize fn f(x: Bool, multiplier: Int64): Int64 { 9 | let result = if x { 10 | 10 11 | } else { 12 | 20 13 | }; 14 | result * multiplier 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/if-phi-return-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(true) == 10); 5 | assert(f(false) == 20); 6 | } 7 | 8 | @Optimize fn f(x: Bool): Int64 { 9 | if x { 10 | 10 11 | } else { 12 | 20 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/if-return.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(true) == 10); 5 | assert(f(false) == 20); 6 | } 7 | 8 | @Optimize fn f(x: Bool): Int64 { 9 | if x { 10 | return 10; 11 | } else { 12 | return 20; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/inline-multiple-returns1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(true) == 100); 5 | assert(f(false) == 200); 6 | } 7 | 8 | @Optimize fn f(a: Bool): Int64 { g(a) } 9 | @ForceInline fn g(a: Bool): Int64 { 10 | if a { 11 | return 100; 12 | } else { 13 | return 200; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/inline-return-struct1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let result = f(); 5 | assert(result.0 == 12); 6 | assert(result.1 == 17); 7 | } 8 | 9 | struct Foo(Int64, Int64) 10 | 11 | @Optimize fn f(): Foo { g(12, 17) } 12 | @ForceInline fn g(a: Int64, b: Int64): Foo { Foo(a, b) } 13 | -------------------------------------------------------------------------------- /tests/boots/inline-return-tuple1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let result = f(); 5 | assert(result.0 == 12); 6 | assert(result.1 == 17); 7 | } 8 | 9 | @Optimize fn f(): (Int64, Int64) { g(12, 17) } 10 | @ForceInline fn g(a: Int64, b: Int64): (Int64, Int64) { (a, b) } 11 | -------------------------------------------------------------------------------- /tests/boots/inline-return1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f() == 17); 5 | } 6 | 7 | @Optimize fn f(): Int64 { g() } 8 | @ForceInline fn g(): Int64 { 17 } 9 | -------------------------------------------------------------------------------- /tests/boots/inline1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= stdout "Hello inlining!\n" 3 | 4 | fn main() { 5 | f(); 6 | } 7 | 8 | @Optimize fn f() { g() } 9 | @ForceInline fn g() { println("Hello inlining!"); } 10 | -------------------------------------------------------------------------------- /tests/boots/inline2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= stdout "Hello inlining 107!\n" 3 | 4 | fn main() { 5 | f(); 6 | } 7 | 8 | @Optimize fn f() { g(107) } 9 | @ForceInline fn g(x: Int64) { println("Hello inlining ${x}!"); } 10 | -------------------------------------------------------------------------------- /tests/boots/inline3.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error code 1 3 | 4 | fn main() { 5 | f(); 6 | } 7 | 8 | @Optimize fn f() { g() } 9 | @ForceInline fn g() { std::fatalError("error in g()"); } 10 | -------------------------------------------------------------------------------- /tests/boots/loop-increment-counter.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | @Optimize 4 | fn main() { 5 | let set = std::BitSet::new(64); 6 | set.insert(0); 7 | 8 | let mut i = 1; 9 | while i < 63 { 10 | assert(!set.contains(i)); 11 | i = i + 1; 12 | } 13 | 14 | assert(i == 63); 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/mod-int64-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | let x = f(Int64::minValue(), -1); 6 | } 7 | 8 | @Optimize fn f(a: Int64, b: Int64): Int64 { a%b } 9 | -------------------------------------------------------------------------------- /tests/boots/mod-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(9, 4); 5 | assert(x == 1); 6 | let x = f(100, 4); 7 | assert(x == 0); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a%b } 11 | -------------------------------------------------------------------------------- /tests/boots/mul-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1.5f32, 2f32); 5 | assert(x == 3.0f32); 6 | let x = f(100.25f32, 3f32); 7 | assert(x == 300.75f32); 8 | } 9 | 10 | @Optimize fn f(a: Float32, b: Float32): Float32 { a*b } 11 | -------------------------------------------------------------------------------- /tests/boots/mul-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1.5, 2.0); 5 | assert(x == 3.0); 6 | let x = f(100.25, 3.0); 7 | assert(x == 300.75); 8 | } 9 | 10 | @Optimize fn f(a: Float64, b: Float64): Float64 { a*b } 11 | -------------------------------------------------------------------------------- /tests/boots/mul-int32-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | let x = f(Int32::minValue(), -1i32); 6 | } 7 | 8 | @Optimize fn f(a: Int32, b: Int32): Int32 { a*b } 9 | -------------------------------------------------------------------------------- /tests/boots/mul-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(2i32, 4i32); 5 | assert(x == 8i32); 6 | let x = f(100i32, 12i32); 7 | assert(x == 1200i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a*b } 11 | -------------------------------------------------------------------------------- /tests/boots/mul-int64-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | let x = f(Int64::minValue(), -1); 6 | } 7 | 8 | @Optimize fn f(a: Int64, b: Int64): Int64 { a*b } 9 | -------------------------------------------------------------------------------- /tests/boots/mul-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(2, 4); 5 | assert(x == 8); 6 | let x = f(100, 12); 7 | assert(x == 1200); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a*b } 11 | -------------------------------------------------------------------------------- /tests/boots/neg-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(5.0f32); 5 | assert(x == -5.0f32); 6 | let x = f(-100.5f32); 7 | assert(x == 100.5f32); 8 | } 9 | 10 | @Optimize fn f(a: Float32): Float32 { -a } 11 | -------------------------------------------------------------------------------- /tests/boots/neg-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(5.0); 5 | assert(x == -5.0); 6 | let x = f(-100.5); 7 | assert(x == 100.5); 8 | } 9 | 10 | @Optimize fn f(a: Float64): Float64 { -a } 11 | -------------------------------------------------------------------------------- /tests/boots/neg-int32-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | f(Int32::minValue()); 6 | } 7 | 8 | @Optimize fn f(a: Int32): Int32 { -a } 9 | -------------------------------------------------------------------------------- /tests/boots/neg-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(5i32); 5 | assert(x == -5i32); 6 | let x = f(100i32); 7 | assert(x == -100i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32): Int32 { -a } 11 | -------------------------------------------------------------------------------- /tests/boots/neg-int64-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | f(Int64::minValue()); 6 | } 7 | 8 | @Optimize fn f(a: Int64): Int64 { -a } 9 | -------------------------------------------------------------------------------- /tests/boots/neg-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(5); 5 | assert(x == -5); 6 | let x = f(100); 7 | assert(x == -100); 8 | } 9 | 10 | @Optimize fn f(a: Int64): Int64 { -a } 11 | -------------------------------------------------------------------------------- /tests/boots/nested-loop1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "0/0:0/1:1/0:1/1:2/0:2/1:" 2 | //= boots 3 | 4 | fn main() { 5 | f(); 6 | } 7 | 8 | @Optimize 9 | fn f() { 10 | for i in std::range(0, 3) { 11 | for j in std::range(0, 2) { 12 | print("${i}/${j}:"); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/not-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(-5i32); 5 | assert(x == 4i32); 6 | let x = f(-1i32); 7 | assert(x == 0i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32): Int32 { !a } 11 | -------------------------------------------------------------------------------- /tests/boots/not-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(-5); 5 | assert(x == 4); 6 | let x = f(-1); 7 | assert(x == 0); 8 | } 9 | 10 | @Optimize fn f(a: Int64): Int64 { !a } 11 | -------------------------------------------------------------------------------- /tests/boots/opt/array-length-twice.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = Array[Int]::zero(10); 5 | assert(f(x) == 20); 6 | } 7 | 8 | @Optimize fn f(x: Array[Int]): Int { 9 | x.size() + x.size() 10 | } -------------------------------------------------------------------------------- /tests/boots/opt/global-multiple-loads-in-block1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let g: Int64 = 10; 4 | 5 | fn main() { 6 | assert(getg() == 40); 7 | } 8 | 9 | @Optimize fn getg(): Int64 { 10 | g + g + g + g 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/opt/global-multiple-loads-in-block2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | let mut g: Int64 = 10; 4 | 5 | fn main() { 6 | assert(getg() == 60); 7 | } 8 | 9 | @Optimize fn getg(): Int64 { 10 | let result = g + g; 11 | updateg(); 12 | result + g + g 13 | } 14 | 15 | @NeverInline fn updateg() { 16 | g = 20; 17 | } 18 | -------------------------------------------------------------------------------- /tests/boots/opt/if-const.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(ifTrue() == 2); 5 | } 6 | 7 | @Optimize fn ifTrue(): Int { 8 | if true { 9 | 2 10 | } else { 11 | 3 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/opt/infinite-loop1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | f(0i32); 5 | } 6 | 7 | @Optimize fn f(mut idx: Int32) { 8 | while true { 9 | std::exit(idx); 10 | idx = idx + 1i32; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/opt/option-get-or-panic.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(get(Some[Int](10)) == 10); 5 | } 6 | 7 | @Optimize fn get(x: Option[Int]): Int { 8 | x.getOrPanic() 9 | } 10 | -------------------------------------------------------------------------------- /tests/boots/option-match1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(!isNone(Some[Foo](Foo(10)))); 5 | assert(isNone(None[Foo])); 6 | } 7 | 8 | class Foo { value: Int64 } 9 | 10 | @Optimize fn isNone(value: Option[Foo]): Bool { 11 | match value { 12 | None => true, 13 | _ => false, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/option-match2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(isSome(Some[Foo](Foo(10)))); 5 | assert(!isSome(None[Foo])); 6 | } 7 | 8 | class Foo { value: Int64 } 9 | 10 | @Optimize fn isSome(value: Option[Foo]): Bool { 11 | match value { 12 | Some(_) => true, 13 | _ => false, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/option-match3.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(Some[Foo](Foo(10))) == 10); 5 | assert(f(None[Foo]) == -1); 6 | } 7 | 8 | class Foo { value: Int64 } 9 | 10 | @Optimize fn f(value: Option[Foo]): Int64 { 11 | match value { 12 | Some(foo) => foo.value, 13 | _ => -1, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/option-new1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f().isNone()); 5 | } 6 | 7 | class Foo { value: Int64 } 8 | 9 | @Optimize fn f(): Option[Foo] { 10 | None 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/option-new2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(10); 5 | assert(f(foo).isSome()); 6 | } 7 | 8 | class Foo { value: Int64 } 9 | 10 | @Optimize fn f(value: Foo): Option[Foo] { 11 | Some[Foo](value) 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/option-new3.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = f(10); 5 | match foo { 6 | Some(x) => assert(x == 10), 7 | _ => unreachable[()](), 8 | } 9 | } 10 | 11 | @Optimize fn f(value: Int64): Option[Int64] { 12 | Some[Int64](value) 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/or-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3i32, 4i32); 5 | assert(x == 7i32); 6 | let x = f(1i32, 2i32); 7 | assert(x == 3i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a | b } 11 | -------------------------------------------------------------------------------- /tests/boots/or-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3, 4); 5 | assert(x == 7); 6 | let x = f(1, 2); 7 | assert(x == 3); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a | b } 11 | -------------------------------------------------------------------------------- /tests/boots/result-new1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(10); 5 | assert(f(foo).isOk()); 6 | } 7 | 8 | class Foo { value: Int64 } 9 | class Bar { value: Int64 } 10 | 11 | @Optimize fn f(foo: Foo): Result[Foo, Bar] { 12 | Ok[Foo, Bar](foo) 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/return-bool-arg.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(true)); 5 | assert(!(f(false))); 6 | } 7 | 8 | @Optimize fn f(x: Bool): Bool { x } 9 | -------------------------------------------------------------------------------- /tests/boots/return-bool-const.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f()); 5 | assert(!g()); 6 | } 7 | 8 | @Optimize fn f(): Bool { true } 9 | @Optimize fn g(): Bool { false } 10 | -------------------------------------------------------------------------------- /tests/boots/return-char-const.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(); 5 | assert(x == 'f'); 6 | let x = g(); 7 | assert(x == 'g'); 8 | let x = h(); 9 | assert(x == 'h'); 10 | } 11 | 12 | @Optimize fn f(): Char { 'f' } 13 | @Optimize fn g(): Char { 'g' } 14 | @Optimize fn h(): Char { 'h' } 15 | -------------------------------------------------------------------------------- /tests/boots/return-float32-arg.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(12.5f32); 5 | assert(x == 12.5f32); 6 | let x = f(-100.25f32); 7 | assert(x == -100.25f32); 8 | } 9 | 10 | @Optimize fn f(x: Float32): Float32 { x } 11 | -------------------------------------------------------------------------------- /tests/boots/return-float32-const.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(); 5 | assert(x == 12.5f32); 6 | let x = g(); 7 | assert(x == 100.25f32); 8 | } 9 | 10 | @Optimize fn f(): Float32 { 12.5f32 } 11 | @Optimize fn g(): Float32 { 100.25f32 } 12 | -------------------------------------------------------------------------------- /tests/boots/return-float64-arg.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(12.5); 5 | assert(x == 12.5); 6 | let x = f(-100.25); 7 | assert(x == -100.25); 8 | } 9 | 10 | @Optimize fn f(x: Float64): Float64 { x } 11 | -------------------------------------------------------------------------------- /tests/boots/return-float64-const.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(); 5 | assert(x == 12.5); 6 | let x = g(); 7 | assert(x == 100.25); 8 | } 9 | 10 | @Optimize fn f(): Float64 { 12.5 } 11 | @Optimize fn g(): Float64 { 100.25 } 12 | -------------------------------------------------------------------------------- /tests/boots/return-int32-arg.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(12i32); 5 | assert(x == 12i32); 6 | let x = f(13i32); 7 | assert(x == 13i32); 8 | } 9 | 10 | @Optimize fn f(x: Int32): Int32 { x } 11 | -------------------------------------------------------------------------------- /tests/boots/return-int32-const.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(); 5 | assert(x == 12i32); 6 | let x = g(); 7 | assert(x == 13i32); 8 | let x = h(); 9 | assert(x == -1i32); 10 | } 11 | 12 | @Optimize fn f(): Int32 { 12i32 } 13 | @Optimize fn g(): Int32 { 13i32 } 14 | @Optimize fn h(): Int32 { -1i32 } 15 | -------------------------------------------------------------------------------- /tests/boots/return-int64-arg.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(12); 5 | assert(x == 12); 6 | let x = f(13); 7 | assert(x == 13); 8 | } 9 | 10 | @Optimize fn f(x: Int64): Int64 { x } 11 | -------------------------------------------------------------------------------- /tests/boots/return-int64-const.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(); 5 | assert(x == 12); 6 | let x = g(); 7 | assert(x == 13); 8 | let x = h(); 9 | assert(x == -1); 10 | } 11 | 12 | @Optimize fn f(): Int64 { 12 } 13 | @Optimize fn g(): Int64 { 13 } 14 | @Optimize fn h(): Int64 { -1 } 15 | -------------------------------------------------------------------------------- /tests/boots/return-lambda-context.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(12); 5 | assert(x() == 12); 6 | } 7 | 8 | @Optimize fn f(a: Int64): (): Int64 { 9 | ||: Int64 { a } 10 | } 11 | -------------------------------------------------------------------------------- /tests/boots/return-lambda.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(); 5 | assert(x() == 12); 6 | } 7 | 8 | @Optimize fn f(): (): Int64 { 9 | ||: Int64 { 12 } 10 | } 11 | -------------------------------------------------------------------------------- /tests/boots/return-pointer.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(Foo(10)).val == 10); 5 | assert(f(Foo(17)).val == 17); 6 | } 7 | 8 | class Foo { val: Int64 } 9 | 10 | @Optimize fn f(x: Foo): Foo { x } 11 | -------------------------------------------------------------------------------- /tests/boots/return-struct-bool.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo(true, false); 5 | assert(f.a); 6 | assert(!f.b); 7 | } 8 | 9 | struct Foo { a: Bool, b: Bool } 10 | 11 | @Optimize fn makefoo(a: Bool, b: Bool): Foo { 12 | Foo(a, b) 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/return-struct-char.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo('1', '2'); 5 | assert(f.a == '1'); 6 | assert(f.b == '2'); 7 | } 8 | 9 | struct Foo { a: Char, b: Char } 10 | 11 | @Optimize fn makefoo(a: Char, b: Char): Foo { 12 | Foo(a, b) 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/return-struct-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo(1.0f32, 2.0f32); 5 | assert(f.a == 1.0f32); 6 | assert(f.b == 2.0f32); 7 | } 8 | 9 | struct Foo { a: Float32, b: Float32 } 10 | 11 | @Optimize fn makefoo(a: Float32, b: Float32): Foo { 12 | Foo(a, b) 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/return-struct-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo(1.0, 2.0); 5 | assert(f.a == 1.0); 6 | assert(f.b == 2.0); 7 | } 8 | 9 | struct Foo { a: Float64, b: Float64 } 10 | 11 | @Optimize fn makefoo(a: Float64, b: Float64): Foo { 12 | Foo(a, b) 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/return-struct-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo(1, 2); 5 | assert(f.a == 1); 6 | assert(f.b == 2); 7 | } 8 | 9 | struct Foo { a: Int64, b: Int64 } 10 | 11 | @Optimize fn makefoo(a: Int64, b: Int64): Foo { 12 | Foo(a, b) 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/return-struct-uint8.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo(1u8, 2u8); 5 | assert(f.a == 1u8); 6 | assert(f.b == 2u8); 7 | } 8 | 9 | struct Foo { a: UInt8, b: UInt8 } 10 | 11 | @Optimize fn makefoo(a: UInt8, b: UInt8): Foo { 12 | Foo(a, b) 13 | } 14 | -------------------------------------------------------------------------------- /tests/boots/return-tuple-nested1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo(1, 2, 3); 5 | assert(f.0 == 1); 6 | assert((f.1).0 == 2); 7 | assert((f.1).1 == 3); 8 | } 9 | 10 | @Optimize fn makefoo(a: Int64, b: Int64, c: Int64): (Int64, (Int64, Int64)) { 11 | (a, (b, c)) 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/return-tuple-nested2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo(1, 2, 3); 5 | assert(f.0 == 1); 6 | assert(f.1.a == 2); 7 | assert(f.1.b == 3); 8 | } 9 | 10 | struct Foo { a: Int64, b: Int64 } 11 | 12 | @Optimize fn makefoo(a: Int64, b: Int64, c: Int64): (Int64, Foo) { 13 | (a, Foo(a = b, b = c)) 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/return-tuple1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let f = makefoo(1, 2); 5 | assert(f.0 == 1); 6 | assert(f.1 == 2); 7 | } 8 | 9 | @Optimize fn makefoo(a: Int64, b: Int64): (Int64, Int64) { 10 | (a, b) 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/return-uint8-const.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(); 5 | assert(x == 0u8); 6 | let x = g(); 7 | assert(x == 1u8); 8 | let x = h(); 9 | assert(x == 255u8); 10 | } 11 | 12 | @Optimize fn f(): UInt8 { 0u8 } 13 | @Optimize fn g(): UInt8 { 1u8 } 14 | @Optimize fn h(): UInt8 { 255u8 } 15 | -------------------------------------------------------------------------------- /tests/boots/sar-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3i32, 1i32); 5 | assert(x == 1i32); 6 | let x = f(-8i32, 2i32); 7 | assert(x == -2i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a >> b } 11 | -------------------------------------------------------------------------------- /tests/boots/sar-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3, 1i32); 5 | assert(x == 1); 6 | let x = f(-8, 2i32); 7 | assert(x == -2); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int32): Int64 { a >> b } 11 | -------------------------------------------------------------------------------- /tests/boots/shl-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3i32, 1i32); 5 | assert(x == 6i32); 6 | let x = f(-8i32, 2i32); 7 | assert(x == -32i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a << b } 11 | -------------------------------------------------------------------------------- /tests/boots/shl-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3, 1i32); 5 | assert(x == 6); 6 | let x = f(-8, 2i32); 7 | assert(x == -32); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int32): Int64 { a << b } 11 | -------------------------------------------------------------------------------- /tests/boots/shr-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3i32, 1i32); 5 | assert(x == 1i32); 6 | let x = f(-8i32, 2i32); 7 | assert(x == 1073741822i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a >>> b } 11 | -------------------------------------------------------------------------------- /tests/boots/shr-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3, 1i32); 5 | assert(x == 1); 6 | let x = f(-8, 2i32); 7 | assert(x == 4611686018427387902); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int32): Int64 { a >>> b } 11 | -------------------------------------------------------------------------------- /tests/boots/struct-load-enum1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(a = 1, bar = Bar::A); 5 | let bar = getbar(foo); 6 | assert(bar == Bar::A); 7 | } 8 | 9 | struct Foo { a: Int64, bar: Bar } 10 | enum Bar { A, B, C } 11 | 12 | @Optimize fn getbar(x: Foo): Bar { 13 | x.bar 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/struct-load-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(a = 1, b = 2); 5 | assert(geta(foo) == 1); 6 | assert(getb(foo) == 2); 7 | } 8 | 9 | struct Foo { a: Int64, b: Int64 } 10 | 11 | @Optimize fn geta(x: Foo): Int64 { 12 | x.a 13 | } 14 | 15 | @Optimize fn getb(x: Foo): Int64 { 16 | x.b 17 | } 18 | -------------------------------------------------------------------------------- /tests/boots/struct-load-tuple1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = Foo(a = 1, bar = (2, 3)); 5 | let bar = getbar(foo); 6 | assert(bar.0 == 2); 7 | assert(bar.1 == 3); 8 | } 9 | 10 | struct Foo { a: Int64, bar: (Int64, Int64) } 11 | 12 | @Optimize fn getbar(x: Foo): (Int64, Int64) { 13 | x.bar 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/sub-float32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(2.5f32, 1.5f32); 5 | assert(x == 1f32); 6 | let x = f(100.25f32, 0.25f32); 7 | assert(x == 100.0f32); 8 | } 9 | 10 | @Optimize fn f(a: Float32, b: Float32): Float32 { a-b } 11 | -------------------------------------------------------------------------------- /tests/boots/sub-float64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(2.5, 1.5); 5 | assert(x == 1.0); 6 | let x = f(100.25, 0.25); 7 | assert(x == 100.0); 8 | } 9 | 10 | @Optimize fn f(a: Float64, b: Float64): Float64 { a-b } 11 | -------------------------------------------------------------------------------- /tests/boots/sub-int32-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | let x = f(Int32::minValue(), 1i32); 6 | } 7 | 8 | @Optimize fn f(a: Int32, b: Int32): Int32 { a-b } 9 | -------------------------------------------------------------------------------- /tests/boots/sub-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1i32, 2i32); 5 | assert(x == -1i32); 6 | let x = f(100i32, 12i32); 7 | assert(x == 88i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a-b } 11 | -------------------------------------------------------------------------------- /tests/boots/sub-int64-overflow.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | //= error overflow 3 | 4 | fn main() { 5 | let x = f(Int64::minValue(), 1); 6 | } 7 | 8 | @Optimize fn f(a: Int64, b: Int64): Int64 { a-b } 9 | -------------------------------------------------------------------------------- /tests/boots/sub-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1, 2); 5 | assert(x == -1); 6 | let x = f(100, 12); 7 | assert(x == 88); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a-b } 11 | -------------------------------------------------------------------------------- /tests/boots/test.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(1, 2); 5 | assert(x == 3); 6 | let x = f(100, 12); 7 | assert(x == 112); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a+b } 11 | -------------------------------------------------------------------------------- /tests/boots/tuple-load-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = (1, 2); 5 | assert(geta(foo) == 1); 6 | assert(getb(foo) == 2); 7 | } 8 | 9 | @Optimize fn geta(x: (Int64, Int64)): Int64 { 10 | x.0 11 | } 12 | 13 | @Optimize fn getb(x: (Int64, Int64)): Int64 { 14 | x.1 15 | } 16 | -------------------------------------------------------------------------------- /tests/boots/tuple-load-struct1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = (1, Foo(a = 2, b = 3)); 5 | let snd = getsnd(foo); 6 | assert(snd.a == 2); 7 | assert(snd.b == 3); 8 | } 9 | 10 | struct Foo { a: Int64, b: Int64 } 11 | 12 | @Optimize fn getsnd(x: (Int64, Foo)): Foo { 13 | x.1 14 | } 15 | -------------------------------------------------------------------------------- /tests/boots/tuple-load-tuple1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let foo = (1, (2, 3)); 5 | let snd = getsnd(foo); 6 | assert(snd.0 == 2); 7 | assert(snd.1 == 3); 8 | } 9 | 10 | @Optimize fn getsnd(x: (Int64, (Int64, Int64))): (Int64, Int64) { 11 | x.1 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/unreachable2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | get(false); 5 | } 6 | 7 | @Optimize fn get(x: Bool) { 8 | while x { 9 | std::unreachable[()](); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/boots/while-phi1.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(12) == 0); 5 | assert(f(9) == 0); 6 | } 7 | 8 | @Optimize fn f(x: Int64): Int64 { 9 | let mut x = x; 10 | while x > 0 { x = x - 1; } 11 | x 12 | } 13 | -------------------------------------------------------------------------------- /tests/boots/while-phi2.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(12) == 24); 5 | assert(f(9) == 18); 6 | } 7 | 8 | @Optimize fn f(x: Int64): Int64 { 9 | let mut x = x; 10 | let mut res = 0; 11 | 12 | while x > 0 { 13 | x = x - 1; 14 | res = res + 2; 15 | } 16 | 17 | res 18 | } 19 | -------------------------------------------------------------------------------- /tests/boots/while-phi4.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | assert(f(3) == 3); 5 | assert(f(5) == 10); 6 | } 7 | 8 | @Optimize fn f(x: Int64): Int64 { 9 | let mut x = x; 10 | let mut res = 0; 11 | let dec = 1; 12 | 13 | while x > 0 { 14 | x = x - dec; 15 | res = res + x; 16 | } 17 | 18 | res 19 | } 20 | -------------------------------------------------------------------------------- /tests/boots/xor-int32.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3i32, 4i32); 5 | assert(x == 7i32); 6 | let x = f(1i32, 3i32); 7 | assert(x == 2i32); 8 | } 9 | 10 | @Optimize fn f(a: Int32, b: Int32): Int32 { a ^ b } 11 | -------------------------------------------------------------------------------- /tests/boots/xor-int64.dora: -------------------------------------------------------------------------------- 1 | //= boots 2 | 3 | fn main() { 4 | let x = f(3, 4); 5 | assert(x == 7); 6 | let x = f(1, 3); 7 | assert(x == 2); 8 | } 9 | 10 | @Optimize fn f(a: Int64, b: Int64): Int64 { a ^ b } 11 | -------------------------------------------------------------------------------- /tests/cannon/assert1.dora: -------------------------------------------------------------------------------- 1 | //= error assert 2 | 3 | fn main() { 4 | let mut x = Foo(12i32); 5 | x.test(); 6 | x.test2(1i32); 7 | } 8 | 9 | class Foo { i: Int32 } 10 | 11 | impl Foo { 12 | fn test() { 13 | let mut x = self.i; 14 | } 15 | 16 | fn test2(i: Int32) { 17 | assert(i == 2i32); 18 | } 19 | } -------------------------------------------------------------------------------- /tests/cannon/gc-in-compiler2.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=copy --gc-stress-in-lazy-compile" 2 | 3 | fn main() { 4 | let mut escaped = 1; 5 | let lambda = |increment: Int64| { escaped = escaped + increment; }; 6 | lambda(10); 7 | assert(escaped == 11); 8 | lambda(2); 9 | assert(escaped == 13); 10 | } 11 | -------------------------------------------------------------------------------- /tests/cannon/neg-int32-overflow.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | f(Int32::minValue()); 5 | } 6 | 7 | fn f(a: Int32): Int32 { -a } 8 | -------------------------------------------------------------------------------- /tests/cannon/neg-int32-wrapping.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = f(Int32::minValue()); 3 | assert(x == Int32::minValue()); 4 | } 5 | 6 | fn f(a: Int32): Int32 { a.wrappingNeg() } 7 | -------------------------------------------------------------------------------- /tests/cannon/neg-int64-overflow.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | f(Int64::minValue()); 5 | } 6 | 7 | fn f(a: Int64): Int64 { -a } 8 | -------------------------------------------------------------------------------- /tests/cannon/neg-int64-wrapping.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = f(Int64::minValue()); 3 | assert(x == Int64::minValue()); 4 | } 5 | 6 | fn f(a: Int64): Int64 { a.wrappingNeg() } 7 | -------------------------------------------------------------------------------- /tests/cannon/while1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut i = 0i32; 3 | while i < 10i32 { 4 | i = i + 1i32; 5 | } 6 | assert(i == 10i32); 7 | } -------------------------------------------------------------------------------- /tests/class/class-assign-unnamed1.dora: -------------------------------------------------------------------------------- 1 | class Foo(Int, Bool) 2 | 3 | fn main() { 4 | let x = Foo(1, true); 5 | set_first(x, 10); 6 | assert(x.0 == 10); 7 | assert(x.1 == true); 8 | } 9 | 10 | fn set_first(foo: Foo, value: Int) { 11 | foo.0 = value; 12 | } 13 | -------------------------------------------------------------------------------- /tests/class/obj1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | Foo(); 3 | } 4 | 5 | class Foo 6 | -------------------------------------------------------------------------------- /tests/class/obj2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let obj = Foo(1i32); 3 | assert(obj.a == 1i32); 4 | } 5 | 6 | class Foo { a: Int32 } 7 | -------------------------------------------------------------------------------- /tests/class/obj3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let o1 = Foo(); 3 | let o2 = o1; 4 | 5 | assert(o1 === o2); 6 | } 7 | 8 | class Foo 9 | -------------------------------------------------------------------------------- /tests/class/obj4.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let i = 1i32; 3 | let o1 = Foo(); 4 | let o2 = o1.me(); 5 | assert(o1 === o2); 6 | } 7 | 8 | class Foo 9 | 10 | impl Foo { 11 | fn me(): Foo { return self; } 12 | } 13 | -------------------------------------------------------------------------------- /tests/class/obj5.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | foo(); 3 | } 4 | 5 | fn foo(): Foo { 6 | return Foo(); 7 | } 8 | 9 | class Foo 10 | -------------------------------------------------------------------------------- /tests/class/obj7.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let f1 = Foo1(1i32); 3 | let f2 = Foo2(a = 1i32, b = 2i32); 4 | assert(f2.a == 1i32); 5 | } 6 | 7 | class Foo1 { a: Int32 } 8 | class Foo2 { a: Int32, b: Int32 } 9 | -------------------------------------------------------------------------------- /tests/empty-world.dora: -------------------------------------------------------------------------------- 1 | fn main() {} -------------------------------------------------------------------------------- /tests/enum/enum-match-underscore1.dora: -------------------------------------------------------------------------------- 1 | enum Foo { A, B, C } 2 | 3 | fn main() { 4 | assert(is_a(Foo::A)); 5 | assert(!is_a(Foo::B)); 6 | assert(!is_a(Foo::C)); 7 | } 8 | 9 | fn is_a(foo: Foo): Bool { 10 | match foo { 11 | Foo::A => true, 12 | _ => false, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/enum/enum-match1.dora: -------------------------------------------------------------------------------- 1 | enum Foo { A, B } 2 | 3 | fn main() { 4 | assert(value(Foo::A) == 1i32); 5 | assert(value(Foo::B) == 2i32); 6 | } 7 | 8 | fn value(foo: Foo): Int32 { 9 | match foo { 10 | Foo::A => 1i32, 11 | Foo::B => 2i32 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/enum/enum-match2.dora: -------------------------------------------------------------------------------- 1 | enum Foo { A(Int32, Int32), B } 2 | 3 | fn main() { 4 | assert(value(Foo::A(2i32, 3i32)) == 5i32); 5 | assert(value(Foo::B) == 0i32); 6 | } 7 | 8 | fn value(foo: Foo): Int32 { 9 | match foo { 10 | Foo::A(a, b) => a + b, 11 | Foo::B => 0 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/enum/enum-match4.dora: -------------------------------------------------------------------------------- 1 | enum Foo { A(Int32, ()), B } 2 | 3 | fn main() { 4 | assert(value(Foo::A(2i32, ())) == 2i32); 5 | assert(value(Foo::B) == 0i32); 6 | } 7 | 8 | fn value(foo: Foo): Int32 { 9 | match foo { 10 | Foo::A(a, b) => a, 11 | Foo::B => 0 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/enum/enum-option2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(Option[String]::Some("abc").getOrPanic() == "abc"); 3 | assert(Option[Int32]::Some(12i32).getOrPanic() == 12i32); 4 | } 5 | -------------------------------------------------------------------------------- /tests/enum/enum-option3.dora: -------------------------------------------------------------------------------- 1 | //= error 2 | 3 | fn main() { 4 | Option[String]::None.getOrPanic(); 5 | } 6 | -------------------------------------------------------------------------------- /tests/enum/enum-option4.dora: -------------------------------------------------------------------------------- 1 | //= error 2 | 3 | fn main() { 4 | Option[Int32]::None.getOrPanic(); 5 | } 6 | -------------------------------------------------------------------------------- /tests/float/float-class.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let f = Foo(1.0); 3 | assert(f.x * 2.0 == 2.0); 4 | } 5 | 6 | class Foo { x: Float64 } 7 | -------------------------------------------------------------------------------- /tests/float/float-global.dora: -------------------------------------------------------------------------------- 1 | let mut x: Float64 = 0.0; 2 | 3 | fn main() { 4 | assert(getx() == 0.0); 5 | 6 | x = 4.0; 7 | assert(getx() == 8.0); 8 | 9 | x = 5.0; 10 | assert(getx() == 10.0); 11 | } 12 | 13 | fn getx(): Float64 { 14 | return x * 2.0; 15 | } -------------------------------------------------------------------------------- /tests/float/float-negative0.dora: -------------------------------------------------------------------------------- 1 | //= stdout "-inf,inf,-inf\n" 2 | fn main() { 3 | let x = -0.0; 4 | let y = 0.0; 5 | let z = "-0.0".toFloat64().getOrPanic(); 6 | println("${1.0/x},${1.0/y},${1.0/z}"); 7 | } 8 | -------------------------------------------------------------------------------- /tests/float/float-scientific.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(1.0e2 == 100.0); 3 | assert(0.250e3 == 250.0); 4 | } -------------------------------------------------------------------------------- /tests/float/float10.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 1i32; 3 | assert(1f32 == x.toFloat32()); 4 | 5 | let y = 5i32; 6 | assert(5f64 == y.toFloat64()); 7 | 8 | let x = 2i64; 9 | assert(2f32 == x.toFloat32()); 10 | 11 | let y = 3i64; 12 | assert(3f64 == y.toFloat64()); 13 | } -------------------------------------------------------------------------------- /tests/float/float11.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 1.1f32; 3 | assert(1i32 == x.toInt32()); 4 | 5 | let y = 213.4f32; 6 | assert(213i64 == y.toInt64()); 7 | 8 | let x = 1.1f64; 9 | assert(1i32 == x.toInt32()); 10 | 11 | let y = 213.4f64; 12 | assert(213i64 == y.toInt64()); 13 | } -------------------------------------------------------------------------------- /tests/float/float12.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 1.75f32; 3 | assert(1.75f64 == x.toFloat64()); 4 | 5 | let x = 2.5f64; 6 | assert(2.5f32 == x.toFloat32()); 7 | } 8 | -------------------------------------------------------------------------------- /tests/float/float2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 0f32 / 0f32; 3 | assert(x.isNan()); 4 | 5 | let x = 3f32; 6 | assert(!x.isNan()); 7 | 8 | let y = 0f64 / 0f64; 9 | assert(y.isNan()); 10 | 11 | let y = 2f64; 12 | assert(!y.isNan()); 13 | } -------------------------------------------------------------------------------- /tests/float/float3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 1f32; 3 | let y = 2f32; 4 | let z = 0f32 / 0f32; 5 | 6 | assert(x == x); 7 | assert(x != y); 8 | 9 | assert(z.isNan()); 10 | assert(z != z); 11 | } -------------------------------------------------------------------------------- /tests/float/float5.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 1f32; 3 | assert(-x < x); 4 | assert(x > -x); 5 | 6 | let x = 1f64; 7 | assert(-x < x); 8 | assert(x > -x); 9 | } -------------------------------------------------------------------------------- /tests/float/float6.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = fone(); 3 | assert(1f32 == x); 4 | 5 | let y = done(); 6 | assert(y == 1f64); 7 | } 8 | 9 | fn fone(): Float32 { 10 | return 1f32; 11 | } 12 | 13 | fn done(): Float64 { 14 | return 1f64; 15 | } -------------------------------------------------------------------------------- /tests/float/float8.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | test(1f32, 2f64, 3i32, 4i64, 5f32, 6f64); 3 | } 4 | 5 | fn test(a: Float32, b: Float64, c: Int32, d: Int64, e: Float32, f: Float64) { 6 | assert(a == 1f32); 7 | assert(b == 2f64); 8 | assert(c == 3i32); 9 | assert(d == 4i64); 10 | assert(e == 5f32); 11 | assert(f == 6f64); 12 | } -------------------------------------------------------------------------------- /tests/float/float9.dora: -------------------------------------------------------------------------------- 1 | //= stdout "1\n1\n" 2 | use std::string::Stringable; 3 | 4 | fn main() { 5 | let x = 1f32; 6 | println(x.toString()); 7 | 8 | let x = 1f64; 9 | println(x.toString()); 10 | } 11 | -------------------------------------------------------------------------------- /tests/for/for-iterator-generic1.dora: -------------------------------------------------------------------------------- 1 | //= ignore 2 | 3 | fn main() { 4 | let arr = Array[Int64]::new(1, 2, 3); 5 | f[std::collections::ArrayIter[Int64]](arr.iter()); 6 | } 7 | 8 | fn f[T: std::traits::Iterator](t: T) { 9 | let mut idx = 0; 10 | for _ in t { 11 | println("${idx}"); 12 | idx = idx + 1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/for/for-range1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "01234" 2 | use std::string::Stringable; 3 | 4 | fn main() { 5 | for i in std::range(0, 5) { 6 | print(i.toString()); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/for/for-range2.dora: -------------------------------------------------------------------------------- 1 | //= stdout "012" 2 | use std::string::Stringable; 3 | 4 | fn main() { 5 | for i in std::range(0, 5) { 6 | if i == 3 { break; } 7 | print(i.toString()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/for/for-range3.dora: -------------------------------------------------------------------------------- 1 | //= stdout "0124" 2 | use std::string::Stringable; 3 | 4 | fn main() { 5 | for i in std::range(0, 5) { 6 | if i == 3 { continue; } 7 | print(i.toString()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/for/for-range4.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut counter = 0; 3 | for i in std::range(0, 0) { 4 | counter = counter + 1; 5 | } 6 | assert(counter == 0); 7 | } 8 | -------------------------------------------------------------------------------- /tests/gc/gc1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Foo(1i32); 3 | std::forceCollect(); 4 | assert(x.a == 1i32); 5 | } 6 | 7 | class Foo { a: Int32 } 8 | -------------------------------------------------------------------------------- /tests/gc/gc11.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let y = test(A(10i32)); 3 | assert(y == 10i32); 4 | } 5 | 6 | class A { x: Int32 } 7 | 8 | fn test(a: A): Int32 { 9 | std::forceCollect(); 10 | return a.x; 11 | } -------------------------------------------------------------------------------- /tests/gc/gc2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | str(); 3 | std::forceCollect(); 4 | } 5 | 6 | fn str() { 7 | let x = "abc"; 8 | let y = "def"; 9 | } 10 | -------------------------------------------------------------------------------- /tests/gc/gc3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = "hello"; 3 | let y = "world"; 4 | 5 | std::forceCollect(); 6 | } 7 | -------------------------------------------------------------------------------- /tests/gc/gc4.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let a = 1i32; 3 | let b = 2i32; 4 | let c = true; 5 | let d = false; 6 | 7 | std::forceCollect(); 8 | } 9 | -------------------------------------------------------------------------------- /tests/gc/gc6.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut x : Option[Foo] = None[Foo]; 3 | 4 | if false { 5 | x = Some[Foo](Foo()); 6 | } 7 | 8 | std::forceCollect(); 9 | } 10 | 11 | class Foo 12 | -------------------------------------------------------------------------------- /tests/gc/gc7.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | foo(); 3 | std::forceCollect(); 4 | foo(); 5 | } 6 | 7 | fn foo() { 8 | let x = "abc"; 9 | assert(x.size() == 3i64); 10 | println(x); 11 | } 12 | -------------------------------------------------------------------------------- /tests/gc/gc9.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = A(10i32); 3 | let y = x; 4 | 5 | std::forceCollect(); 6 | 7 | assert(x === y); 8 | assert(x.a == 10i32); 9 | 10 | } 11 | 12 | class A { a: Int32 } 13 | -------------------------------------------------------------------------------- /tests/generic/generic-call1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "hello\n" 2 | 3 | trait Foo { 4 | fn bar(); 5 | } 6 | 7 | fn foo[T: Foo](t: T) { 8 | t.bar(); 9 | } 10 | 11 | class X 12 | 13 | impl Foo for X { 14 | fn bar() { 15 | println("hello"); 16 | } 17 | } 18 | 19 | fn main() { 20 | foo[X](X()); 21 | } -------------------------------------------------------------------------------- /tests/generic/generic-fct-type-args1.dora: -------------------------------------------------------------------------------- 1 | trait Foo { 2 | fn bar[T](x: T); 3 | } 4 | 5 | class Bar 6 | 7 | impl Foo for Bar { 8 | fn bar[T](x: T) {} 9 | } 10 | 11 | fn myf[T: Foo](x: T) { 12 | x.bar[Int](1); 13 | } 14 | 15 | fn main() { 16 | let bar = Bar(); 17 | myf[Bar](bar); 18 | } 19 | -------------------------------------------------------------------------------- /tests/generic/generic-new-array1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(0i64 == newArray[Int32]().size()); 3 | assert(0i64 == newArray[()]().size()); 4 | } 5 | 6 | fn newArray[T](): Array[T] { 7 | Array[T]::new() 8 | } 9 | -------------------------------------------------------------------------------- /tests/generic/generic-static-fct-type-args1.dora: -------------------------------------------------------------------------------- 1 | trait Foo { 2 | static fn bar[T](x: T); 3 | } 4 | 5 | class Bar 6 | 7 | impl Foo for Bar { 8 | static fn bar[T](x: T) {} 9 | } 10 | 11 | fn myf[T: Foo]() { 12 | T::bar[Int](1); 13 | } 14 | 15 | fn main() { 16 | myf[Bar](); 17 | } 18 | -------------------------------------------------------------------------------- /tests/generic/generic1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "1" 2 | use std::string::Stringable; 3 | 4 | fn main() { 5 | let a = A[Int32](1i32); 6 | print(a.x.toString()); 7 | } 8 | 9 | class A[T] { x: T } 10 | -------------------------------------------------------------------------------- /tests/generic/generic2.dora: -------------------------------------------------------------------------------- 1 | //= stdout "hello1" 2 | use std::string::Stringable; 3 | 4 | fn main() { 5 | let a = A[String](foo(1i32)); 6 | std::forceCollect(); 7 | print(a.x); 8 | } 9 | 10 | class A[T] { x: T } 11 | 12 | fn foo(a: Int32): String { 13 | return "hello" + a.toString(); 14 | } 15 | -------------------------------------------------------------------------------- /tests/generic/generic6.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | foo[Int32](1i32); 3 | foo[Float32](3f32); 4 | foo[String]("hello"); 5 | } 6 | 7 | fn foo[T](val: T) {} -------------------------------------------------------------------------------- /tests/generic/generic7.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(1i32 == foo[Int32](1i32)); 3 | assert(3f32 == foo[Float32](3f32)); 4 | assert("hel" + "lo" == foo[String]("hello")); 5 | } 6 | 7 | fn foo[T](val: T): T { return val; } 8 | -------------------------------------------------------------------------------- /tests/generic/generic8.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let a = A[Int32]::new(); 3 | consume(a.x); 4 | } 5 | 6 | class A[T] { x: Array[T] } 7 | 8 | impl[T] A[T] { 9 | static fn new(): A[T] { 10 | A[T](Array[T]::new()) 11 | } 12 | } 13 | 14 | fn consume(x: Array[Int32]) { 15 | assert(x.size() == 0i64); 16 | } 17 | -------------------------------------------------------------------------------- /tests/hello-world.dora: -------------------------------------------------------------------------------- 1 | //= stdout "Hello, world!\n" 2 | 3 | fn main() { 4 | println("Hello, world!"); 5 | } 6 | -------------------------------------------------------------------------------- /tests/impl/impl1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "xyz\n" 2 | 3 | trait Foo { 4 | fn bla(); 5 | } 6 | 7 | class A 8 | 9 | impl Foo for A { 10 | fn bla() { 11 | println("xyz"); 12 | } 13 | } 14 | 15 | fn main() { 16 | let a = A(); 17 | a.bla(); 18 | } 19 | -------------------------------------------------------------------------------- /tests/impl/impl2.dora: -------------------------------------------------------------------------------- 1 | //= stdout "1\n" 2 | 3 | use std::string::Stringable; 4 | 5 | trait Foo { 6 | fn bla(); 7 | } 8 | 9 | class A { val: Int32 } 10 | 11 | impl Foo for A { 12 | fn bla() { 13 | println(self.val.toString()); 14 | } 15 | } 16 | 17 | fn main() { 18 | let a = A(1i32); 19 | a.bla(); 20 | } 21 | -------------------------------------------------------------------------------- /tests/impl/impl3.dora: -------------------------------------------------------------------------------- 1 | trait Adder { 2 | fn add_me(other: Self): Self; 3 | } 4 | 5 | class A { a: Int32 } 6 | 7 | impl Adder for A { 8 | fn add_me(other: A): A { 9 | return A(self.a + other.a); 10 | } 11 | } 12 | 13 | fn main() { 14 | let x = A(3i32).add_me(A(7i32)); 15 | assert(x.a == 10i32); 16 | } -------------------------------------------------------------------------------- /tests/impl/impl4.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = A::default(); 3 | assert(x.a == 0i32); 4 | } 5 | 6 | trait DefaultValue { 7 | static fn default(): Self; 8 | } 9 | 10 | class A { a: Int32 } 11 | 12 | impl DefaultValue for A { 13 | static fn default(): A { 14 | return A(0i32); 15 | } 16 | } -------------------------------------------------------------------------------- /tests/int/div-zero1.dora: -------------------------------------------------------------------------------- 1 | //= error div0 2 | //= stderr "division by 0\n divide (tests/int/div-zero1.dora:9:5)\n main (tests/int/div-zero1.dora:5:5)\n" 3 | 4 | fn main() { 5 | divide(0i32); 6 | } 7 | 8 | fn divide(x: Int32): Int32 { 9 | 4711i32 / x 10 | } -------------------------------------------------------------------------------- /tests/int/div-zero2.dora: -------------------------------------------------------------------------------- 1 | //= error div0 2 | //= stderr "division by 0\n divide (tests/int/div-zero2.dora:9:5)\n main (tests/int/div-zero2.dora:5:5)\n" 3 | 4 | fn main() { 5 | divide(0i64); 6 | } 7 | 8 | fn divide(x: Int64): Int64 { 9 | 4711i64 / x 10 | } 11 | -------------------------------------------------------------------------------- /tests/int/expr2.dora: -------------------------------------------------------------------------------- 1 | use std::string::Stringable; 2 | 3 | fn main() { 4 | let val = 101i32.toString(); 5 | assert(val == "101"); 6 | } 7 | -------------------------------------------------------------------------------- /tests/int/expr4.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | f(g()); 3 | } 4 | 5 | fn f(a: Int32) { assert(a == 1i32); } 6 | fn g(): Int32 { return 1i32; } 7 | -------------------------------------------------------------------------------- /tests/int/expr7.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(true); 3 | assert(!false); 4 | 5 | assert(true == true); 6 | assert(true != false); 7 | } 8 | -------------------------------------------------------------------------------- /tests/int/int-unchecked-add1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(Int32::minValue() == Int32::maxValue().wrappingAdd(1i32)); 3 | assert(Int64::minValue() == Int64::maxValue().wrappingAdd(1i64)); 4 | } 5 | -------------------------------------------------------------------------------- /tests/int/int-unchecked-mul1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(Int32::minValue() == Int32::minValue().wrappingMul(-1i32)); 3 | assert(Int64::minValue() == Int64::minValue().wrappingMul(-1i64)); 4 | } 5 | -------------------------------------------------------------------------------- /tests/int/int-unchecked-sub1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(Int32::maxValue() == Int32::minValue().wrappingSub(1i32)); 3 | assert(Int64::maxValue() == Int64::minValue().wrappingSub(1i64)); 4 | } 5 | -------------------------------------------------------------------------------- /tests/int/int2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x: Int32 = 2147483647i32; 3 | let y: Int32 = -2147483648i32; 4 | } 5 | -------------------------------------------------------------------------------- /tests/int/int32-overflow-add1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int32::maxValue() + 1i32; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int32-overflow-div1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int32::minValue() / -1i32; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int32-overflow-mod1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int32::minValue() % -1i32; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int32-overflow-mul1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int32::minValue() * -1i32; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int32-overflow-sub1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int32::minValue() - 1i32; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int64-1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 1i32.toInt64(); 3 | let y = id(x); 4 | 5 | assert(x == y); 6 | assert(x >= y); 7 | assert(x <= y); 8 | assert(!(x > y)); 9 | assert(!(x < y)); 10 | } 11 | 12 | fn id(val: Int64): Int64 { 13 | return val; 14 | } 15 | -------------------------------------------------------------------------------- /tests/int/int64-2.dora: -------------------------------------------------------------------------------- 1 | use std::traits::Add; 2 | 3 | fn main() { 4 | let x: Int64 = 1i64; 5 | let y = 2i64; 6 | let z = x.add(y); 7 | assert(3i64 == z); 8 | } -------------------------------------------------------------------------------- /tests/int/int64-4.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(three().toInt32() == 3i32); 3 | } 4 | 5 | fn three(): Int64 { 6 | return 3i64; 7 | } 8 | -------------------------------------------------------------------------------- /tests/int/int64-overflow-add1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int64::maxValue() + 1i64; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int64-overflow-div1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int64::minValue() / -1i64; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int64-overflow-mod1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int64::minValue() % -1i64; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int64-overflow-mul1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int64::minValue() * -1i64; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/int64-overflow-sub1.dora: -------------------------------------------------------------------------------- 1 | //= error overflow 2 | 3 | fn main() { 4 | let x = Int64::minValue() - 1i64; 5 | } 6 | -------------------------------------------------------------------------------- /tests/int/shl1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(1i32 == 1i32 << 0i32); 3 | assert(2i32 == 1i32 << 1i32); 4 | assert(4i32 == 1i32 << 2i32); 5 | assert(8i32 == 1i32 << 3i32); 6 | } 7 | -------------------------------------------------------------------------------- /tests/int/zero.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(zero() == 0i32); 3 | } 4 | 5 | fn zero(): Int32 { 0i32 } 6 | -------------------------------------------------------------------------------- /tests/io/123.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /tests/io/abc.txt: -------------------------------------------------------------------------------- 1 | abc -------------------------------------------------------------------------------- /tests/io/file-create1.dora: -------------------------------------------------------------------------------- 1 | use std::io::Write; 2 | 3 | fn main() { 4 | let file = std::io::File::create("tests/io/test123.txt"); 5 | let bytes = "hello\n".asBytes(); 6 | let written = file.write(bytes, 0, bytes.size()); 7 | assert(written.getOrPanic() == 6); 8 | file.close(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/io/read-as-string1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let content = std::io::File::new("tests/io/abc.txt").readAsString().getOrPanic(); 3 | assert(content == "abc"); 4 | 5 | let content = std::io::File::new("unknown.txt").readAsString(); 6 | assert(content.isErr()); 7 | } 8 | -------------------------------------------------------------------------------- /tests/io/stderr1.dora: -------------------------------------------------------------------------------- 1 | //= stderr "Hello, world!\n" 2 | use std::io::Write; 3 | 4 | fn main() { 5 | let bytes = "Hello, world!\n".asBytes(); 6 | std::io::stderr.write(bytes, 0, bytes.size()); 7 | } 8 | -------------------------------------------------------------------------------- /tests/io/stdout1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "Hello, world!\n" 2 | use std::io::Write; 3 | 4 | fn main() { 5 | let bytes = "Hello, world!\n".asBytes(); 6 | std::io::stdout.write(bytes, 0, bytes.size()); 7 | } 8 | -------------------------------------------------------------------------------- /tests/io/write-as-bytes1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let file = std::io::File::new("tests/io/write-as-bytes1.txt"); 3 | let bytes = Array[UInt8]::new(1u8, 2u8, 3u8, 4u8); 4 | file.writeAsBytes(bytes); 5 | assert(file.readAsBytes().getOrPanic() == bytes); 6 | } 7 | -------------------------------------------------------------------------------- /tests/io/write-as-string1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let file = std::io::File::new("tests/io/write-as-string1.txt"); 3 | file.writeAsString("bla"); 4 | assert(file.readAsString().getOrPanic() == "bla"); 5 | } 6 | -------------------------------------------------------------------------------- /tests/lambda/lambda-call.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=swiper --gc-verify" 2 | 3 | fn main() { 4 | let x = 10; 5 | let lambda = |a: Int64, b: Int64|: Int64 { 6 | let x = 100; 7 | a + b + x 8 | }; 9 | std::forceCollect(); 10 | assert(lambda(1, 2) == 103); 11 | assert(lambda(-2, 4) == 102); 12 | } 13 | -------------------------------------------------------------------------------- /tests/lambda/lambda-context-gc.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=swiper --gc-verify" 2 | 3 | fn main() { 4 | let x = f(12); 5 | std::forceCollect(); 6 | assert(x() == 12); 7 | } 8 | 9 | fn f(a: Int64): (): Int64 { 10 | std::forceCollect(); 11 | ||: Int64 { a } 12 | } 13 | -------------------------------------------------------------------------------- /tests/lambda/lambda-new.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=swiper --gc-verify" 2 | 3 | fn main() { 4 | let lambda: (): Int64 = ||: Int64 { 0 }; 5 | std::forceCollect(); 6 | } 7 | -------------------------------------------------------------------------------- /tests/language/assert1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let a = true; 3 | assert(a); 4 | 5 | let b = false; 6 | assert(!b); 7 | } 8 | -------------------------------------------------------------------------------- /tests/language/assert2.dora: -------------------------------------------------------------------------------- 1 | //= error assert 2 | 3 | fn main() { 4 | let a = false; 5 | assert(a); 6 | } 7 | -------------------------------------------------------------------------------- /tests/language/assert3.dora: -------------------------------------------------------------------------------- 1 | //= error assert 2 | 3 | fn main() { 4 | f(false); 5 | } 6 | 7 | fn f(a: Bool) { 8 | g(a); 9 | } 10 | 11 | fn g(a: Bool) { 12 | h(a); 13 | } 14 | 15 | fn h(a: Bool) { 16 | assert(a); 17 | } 18 | -------------------------------------------------------------------------------- /tests/language/block-expr-gc.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=copy --disable-tlab --gc-stress" 2 | 3 | class Foo { value: Int32 } 4 | 5 | fn main() { 6 | let tpl: Foo = if false { 7 | createFoo() 8 | } else { 9 | std::forceCollect(); 10 | createFoo() 11 | }; 12 | } 13 | 14 | fn createFoo(): Foo { Foo(1i32) } 15 | -------------------------------------------------------------------------------- /tests/language/bool-tostring.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(true.toStringBinary() == "1"); 3 | assert(false.toStringBinary() == "0"); 4 | 5 | assert(true.toStringHex() == "1"); 6 | assert(false.toStringHex() == "0"); 7 | } 8 | -------------------------------------------------------------------------------- /tests/language/bool1.dora: -------------------------------------------------------------------------------- 1 | use std::traits::Not; 2 | 3 | fn main() { 4 | assert(true.toInt32() == 1i32); 5 | assert(false.toInt32() == 0i32); 6 | assert(true.not() == false); 7 | assert(false.not() == true); 8 | } 9 | -------------------------------------------------------------------------------- /tests/language/break1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut i = 0i32; 3 | let mut sum = 0i32; 4 | 5 | while i < 10i32 { 6 | if i == 4i32 { break; } 7 | i = i + 1i32; 8 | sum = sum + i; 9 | } 10 | 11 | assert(i == 4i32); 12 | assert(sum == 10i32); 13 | } 14 | -------------------------------------------------------------------------------- /tests/language/char3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 97i32.toChar().getOrPanic(); 3 | assert(x == 'a'); 4 | 5 | let y = 65i64.toChar().getOrPanic(); 6 | assert(y == 'A'); 7 | } 8 | -------------------------------------------------------------------------------- /tests/language/cmp1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(1i32 < 2i32); 3 | assert(-4i32 < 2i32); 4 | 5 | assert(2i32 > 1i32); 6 | assert(-5i32 > -10i32); 7 | 8 | assert(2i32 == 2i32); 9 | assert(-2i32 != 2i32); 10 | 11 | assert(2i32 <= 2i32); 12 | assert(1i32 <= 2i32); 13 | 14 | assert(-3i32 >= -3i32); 15 | assert(100i32 >= 0i32); 16 | } 17 | -------------------------------------------------------------------------------- /tests/language/const2.dora: -------------------------------------------------------------------------------- 1 | const i: Int32 = -1i32; 2 | const l: Int64 = -2i64; 3 | const no: Bool = false; 4 | const f: Float32 = -3.0f32; 5 | const d: Float64 = -4.0; 6 | 7 | fn main() { 8 | assert(i == -1i32); 9 | assert(l == -2i64); 10 | assert(no == false); 11 | assert(f == -3.0f32); 12 | assert(d == -4.0); 13 | } 14 | -------------------------------------------------------------------------------- /tests/language/fn1.dora: -------------------------------------------------------------------------------- 1 | fn main(): Int32 { 2 | return myzero(); 3 | } 4 | 5 | fn myzero(): Int32 { 6 | return 0i32; 7 | } 8 | -------------------------------------------------------------------------------- /tests/language/fn3.dora: -------------------------------------------------------------------------------- 1 | //= error code 2 2 | 3 | fn main(): Int32 { 4 | return 2i32; 5 | } 6 | -------------------------------------------------------------------------------- /tests/language/fn5.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = 1i32 + myzero(); 3 | assert(result == 1i32); 4 | } 5 | 6 | fn myzero(): Int32 { 7 | return 0i32; 8 | } 9 | -------------------------------------------------------------------------------- /tests/language/fn7.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(f(1i32) == 2i32); 3 | } 4 | 5 | fn f(a: Int32): Int32 { a + 1i32 } 6 | -------------------------------------------------------------------------------- /tests/language/fn8.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let a = 1i32; 3 | assert(Foo(a+1i32).a == 2i32); 4 | } 5 | 6 | class Foo { a: Int32 } 7 | -------------------------------------------------------------------------------- /tests/language/global1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "x = 0\ny = 0\nz = 0\n" 2 | use std::string::Stringable; 3 | 4 | let mut x: Int32 = 0i32; 5 | let mut y: Int32 = 0i32; 6 | let mut z: Int32 = 0i32; 7 | 8 | fn main() { 9 | println("x = " + x.toString()); 10 | println("y = " + y.toString()); 11 | println("z = " + z.toString()); 12 | } 13 | -------------------------------------------------------------------------------- /tests/language/global7.dora: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | a: Int64, 3 | b: Int64, 4 | c: Int64, 5 | } 6 | 7 | let foo: Foo = Foo(a = 100, b = 200, c = 300); 8 | 9 | fn main() { 10 | let tmp = foo; 11 | assert(tmp.a == 100); 12 | assert(tmp.b == 200); 13 | assert(tmp.c == 300); 14 | } 15 | -------------------------------------------------------------------------------- /tests/language/global8.dora: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | a: Int64, 3 | b: Int64, 4 | c: Int64, 5 | } 6 | 7 | let mut foo: Foo = Foo(a = 100, b = 200, c = 300); 8 | 9 | fn main() { 10 | foo = Foo(a = 300, b = 400, c = 500); 11 | assert(foo.a == 300); 12 | assert(foo.b == 400); 13 | assert(foo.c == 500); 14 | } 15 | -------------------------------------------------------------------------------- /tests/language/global9.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(foo::bar == 10); 3 | } 4 | 5 | mod foo { 6 | pub let mut bar: Int64 = 10; 7 | } 8 | -------------------------------------------------------------------------------- /tests/language/is1.dora: -------------------------------------------------------------------------------- 1 | enum Foo { A, B } 2 | 3 | fn main() { 4 | assert(isA(Foo::A)); 5 | assert(!isA(Foo::B)); 6 | assert(isB(Foo::B)); 7 | assert(!isB(Foo::A)); 8 | } 9 | 10 | fn isA(x: Foo): Bool { 11 | x is Foo::A 12 | } 13 | 14 | fn isB(x: Foo): Bool { 15 | x is Foo::B 16 | } 17 | -------------------------------------------------------------------------------- /tests/language/noop-calls.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | f(); 3 | } 4 | 5 | fn f() { 6 | g(); 7 | } 8 | 9 | fn g() {} 10 | -------------------------------------------------------------------------------- /tests/language/pattern-class1.dora: -------------------------------------------------------------------------------- 1 | class Foo { a: Int64, b: Int64 } 2 | 3 | fn main() { 4 | assert(f(Foo(a=1, b=2)) == 3); 5 | } 6 | 7 | fn f(x: Foo): Int64 { 8 | let Foo(a, b) = x; 9 | a + b 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-enum1.dora: -------------------------------------------------------------------------------- 1 | enum Foo { A(Int64), B } 2 | 3 | fn main() { 4 | assert(f(Foo::A(12)) == 12); 5 | assert(f(Foo::A(0)) == 0); 6 | assert(f(Foo::A(-17)) == -17); 7 | } 8 | 9 | fn f(x: Foo): Int64 { 10 | let Foo::A(y) = x; 11 | y 12 | } 13 | -------------------------------------------------------------------------------- /tests/language/pattern-enum2.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | enum Foo { A(Int64), B } 4 | 5 | fn main() { 6 | assert(f(Foo::B) == 12); 7 | } 8 | 9 | fn f(x: Foo): Int64 { 10 | let Foo::A(y) = x; 11 | y 12 | } 13 | -------------------------------------------------------------------------------- /tests/language/pattern-enum3.dora: -------------------------------------------------------------------------------- 1 | enum Foo { A(Int64), B(Int64), C } 2 | 3 | fn main() { 4 | assert(f(Foo::A(10)) == 10); 5 | assert(f(Foo::B(17)) == 17); 6 | } 7 | 8 | fn f(x: Foo): Int64 { 9 | match x { 10 | Foo::A(x) | Foo::B(x) => x, 11 | Foo::C => 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/language/pattern-expr1.dora: -------------------------------------------------------------------------------- 1 | enum Foo { A(Int64), B } 2 | 3 | fn main() { 4 | assert(f(Foo::A(12))); 5 | assert(!f(Foo::B)); 6 | assert(!f(Foo::A(-1))); 7 | assert(!f(Foo::A(-17))); 8 | assert(!f(Foo::A(0))); 9 | assert(f(Foo::A(1))); 10 | } 11 | 12 | fn f(x: Foo): Bool { 13 | x is Foo::A(y) && y > 0 14 | } 15 | -------------------------------------------------------------------------------- /tests/language/pattern-if6.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(myf(true, Some[Int](1)) == 2); 3 | assert(myf(true, Some[Int](7)) == 14); 4 | } 5 | 6 | fn myf(v: Bool, x: Option[Int]): Int { 7 | if v && x is Some(x) && x > 0 { 8 | x * 2 9 | } else { 10 | 0 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-bool1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(f((0, true)) == 0); 3 | assert(f((2, true)) == 2); 4 | assert(f((17, true)) == 17); 5 | } 6 | 7 | fn f(x: (Int64, Bool)): Int64 { 8 | let (a, true) = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-bool2.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | assert(f((0, false)) == 0); 5 | } 6 | 7 | fn f(x: (Int64, Bool)): Int64 { 8 | let (a, true) = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-char1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(f((0, 't')) == 0); 3 | assert(f((2, 't')) == 2); 4 | assert(f((17, 't')) == 17); 5 | } 6 | 7 | fn f(x: (Int64, Char)): Int64 { 8 | let (a, 't') = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-char2.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | assert(f((0, 'f')) == 0); 5 | } 6 | 7 | fn f(x: (Int64, Char)): Int64 { 8 | let (a, 't') = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-float1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(f((0, 2.5f32)) == 0); 3 | assert(f((2, 2.5f32)) == 2); 4 | assert(f((17, 2.5f32)) == 17); 5 | } 6 | 7 | fn f(x: (Int64, Float32)): Int64 { 8 | let (a, 2.5f32) = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-float2.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | assert(f((0, 2.75)) == 0); 5 | } 6 | 7 | fn f(x: (Int64, Float64)): Int64 { 8 | let (a, 2.5) = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-int2.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | assert(f((0, 25)) == 0); 5 | } 6 | 7 | fn f(x: (Int64, Int64)): Int64 { 8 | let (a, 2) = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-string1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(f((0, "abc")) == 0); 3 | assert(f((2, "abc")) == 2); 4 | assert(f((17, "abc")) == 17); 5 | } 6 | 7 | fn f(x: (Int64, String)): Int64 { 8 | let (a, "abc") = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-lit-string2.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | assert(f((0, "def")) == 0); 5 | } 6 | 7 | fn f(x: (Int64, String)): Int64 { 8 | let (a, "abc") = x; 9 | a 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/pattern-param-tuple1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | f((2, 3)); 3 | } 4 | 5 | fn f((a, b): (Int, Int)) { 6 | assert(a == 2); 7 | assert(b == 3); 8 | } -------------------------------------------------------------------------------- /tests/language/pattern-struct1.dora: -------------------------------------------------------------------------------- 1 | struct Foo(Int64, Int64) 2 | 3 | fn main() { 4 | assert(f(Foo(1, 2)) == 3); 5 | } 6 | 7 | fn f(x: Foo): Int64 { 8 | let Foo(a, b) = x; 9 | a + b 10 | } 11 | -------------------------------------------------------------------------------- /tests/language/precedence.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 3i32 | 7i32 & 4i32; 3 | assert(x == 7i32); 4 | } 5 | -------------------------------------------------------------------------------- /tests/language/self1.dora: -------------------------------------------------------------------------------- 1 | use std::traits::Equals; 2 | 3 | fn main() { 4 | assert(0.0 == 0.0); 5 | assert(0.0.equals(0.0)); 6 | 7 | assert(0.0f32 == 0.0f32); 8 | assert(0.0f32.equals(0.0f32)); 9 | } 10 | -------------------------------------------------------------------------------- /tests/language/stack-overflow1.dora: -------------------------------------------------------------------------------- 1 | //= error stack-overflow 2 | 3 | fn main() { 4 | f(); 5 | } 6 | 7 | fn f() { 8 | f(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/language/stack-overflow2.dora: -------------------------------------------------------------------------------- 1 | //= error stack-overflow 2 | 3 | fn main() { 4 | std::thread::spawn(|| { 5 | g(); 6 | }); 7 | } 8 | 9 | fn g() { 10 | f(); 11 | } 12 | 13 | fn f() { 14 | f(); 15 | } 16 | -------------------------------------------------------------------------------- /tests/ops/ops-add-assign-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Array[Int]::new(1); 5 | result(0) += 2; 6 | assert(result(0) == 3); 7 | result(0) += 2; 8 | assert(result(0) == 5); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-add-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 1; 3 | result += 2; 4 | let fct = ||: Int { result }; 5 | assert(result == 3); 6 | assert(fct() == 3); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-add-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 1); 5 | result.value += 2; 6 | assert(result.value == 3); 7 | result.value += 2; 8 | assert(result.value == 5); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-add-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 1; 2 | 3 | fn main() { 4 | result += 2; 5 | assert(result == 3); 6 | result += 2; 7 | assert(result == 5); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-add-assign-global-path-intrinsic.dora: -------------------------------------------------------------------------------- 1 | mod foo { 2 | pub mod bar { 3 | pub let mut result: Int = 1; 4 | } 5 | } 6 | 7 | fn main() { 8 | foo::bar::result += 2; 9 | assert(foo::bar::result == 3); 10 | foo::bar::result += 2; 11 | assert(foo::bar::result == 5); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-add-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 1; 3 | result += 2; 4 | assert(result == 3); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-add-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Add for MyInt { 4 | fn add(rhs: MyInt): MyInt { 5 | MyInt(self.0 + rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(1); 11 | result += MyInt(2); 12 | assert(result.0 == 3); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-add-assign-outer-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result = 1; 3 | let fct = || { result += 2; }; 4 | fct(); 5 | assert(result == 3); 6 | fct(); 7 | assert(result == 5); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-add1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Add for MyInt { 4 | fn add(rhs: MyInt): MyInt { 5 | MyInt(self.0 + rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(1) + MyInt(2); 11 | assert(result.0 == 3); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-arith-shr1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Sar for MyInt { 4 | fn sar(shift: Int32): MyInt { 5 | MyInt(self.0 >> shift) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(-2) >> 1i32; 11 | assert(result.0 == -1); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-bitand-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(11); 3 | result(0) &= 7; 4 | assert(result(0) == 3); 5 | result(0) &= 1; 6 | assert(result(0) == 1); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-bitand-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 10; 3 | result &= 3; 4 | let fct = ||: Int { result }; 5 | assert(result == 2); 6 | assert(fct() == 2); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-bitand-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 11); 5 | result.value &= 7; 6 | assert(result.value == 3); 7 | result.value &= 1; 8 | assert(result.value == 1); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-bitand-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 11; 2 | 3 | fn main() { 4 | result &= 7; 5 | assert(result == 3); 6 | result &= 1; 7 | assert(result == 1); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-bitand-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 11; 3 | result &= 7; 4 | assert(result == 3); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-bitand-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::BitAnd for MyInt { 4 | fn bitand(rhs: MyInt): MyInt { 5 | MyInt(self.0 & rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(11); 11 | result &= MyInt(7); 12 | assert(result.0 == 3); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-bitand1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::BitAnd for MyInt { 4 | fn bitand(rhs: MyInt): MyInt { 5 | MyInt(self.0 & rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(5) & MyInt(3); 11 | assert(result.0 == 1); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-bitor-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(8); 3 | result(0) |= 2; 4 | assert(result(0) == 10); 5 | result(0) |= 3; 6 | assert(result(0) == 11); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-bitor-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 9; 3 | result |= 3; 4 | let fct = ||: Int { result }; 5 | assert(result == 11); 6 | assert(fct() == 11); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-bitor-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 8); 5 | result.value |= 2; 6 | assert(result.value == 10); 7 | result.value |= 3; 8 | assert(result.value == 11); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-bitor-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 8; 2 | 3 | fn main() { 4 | result |= 2; 5 | assert(result == 10); 6 | result |= 3; 7 | assert(result == 11); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-bitor-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 9; 3 | result |= 3; 4 | assert(result == 11); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-bitor-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::BitOr for MyInt { 4 | fn bitor(rhs: MyInt): MyInt { 5 | MyInt(self.0 | rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(9); 11 | result |= MyInt(3); 12 | assert(result.0 == 11); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-bitor1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::BitOr for MyInt { 4 | fn bitor(rhs: MyInt): MyInt { 5 | MyInt(self.0 | rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(4) | MyInt(1); 11 | assert(result.0 == 5); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-bitxor-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(10); 3 | result(0) ^= 29; 4 | assert(result(0) == 23); 5 | result(0) ^= 7; 6 | assert(result(0) == 16); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-bitxor-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 10; 3 | result ^= 29; 4 | let fct = ||: Int { result }; 5 | assert(result == 23); 6 | assert(fct() == 23); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-bitxor-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 10); 5 | result.value ^= 29; 6 | assert(result.value == 23); 7 | result.value ^= 7; 8 | assert(result.value == 16); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-bitxor-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 10; 2 | 3 | fn main() { 4 | result ^= 29; 5 | assert(result == 23); 6 | result ^= 7; 7 | assert(result == 16); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-bitxor-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 10; 3 | result ^= 29; 4 | assert(result == 23); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-bitxor-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::BitXor for MyInt { 4 | fn bitxor(rhs: MyInt): MyInt { 5 | MyInt(self.0 ^ rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(10); 11 | result ^= MyInt(29); 12 | assert(result.0 == 23); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-bitxor1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::BitXor for MyInt { 4 | fn bitxor(rhs: MyInt): MyInt { 5 | MyInt(self.0 ^ rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(4) ^ MyInt(7); 11 | assert(result.0 == 3); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-div-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(10); 3 | result(0) /= 2; 4 | assert(result(0) == 5); 5 | result(0) /= 3; 6 | assert(result(0) == 1); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-div-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 10; 3 | result /= 2; 4 | let fct = ||: Int { result }; 5 | assert(result == 5); 6 | assert(fct() == 5); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-div-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 10); 5 | result.value /= 2; 6 | assert(result.value == 5); 7 | result.value /= 3; 8 | assert(result.value == 1); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-div-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 10; 2 | 3 | fn main() { 4 | result /= 2; 5 | assert(result == 5); 6 | result /= 3; 7 | assert(result == 1); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-div-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 10; 3 | result /= 2; 4 | assert(result == 5); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-div-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Div for MyInt { 4 | fn div(rhs: MyInt): MyInt { 5 | MyInt(self.0 / rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(10); 11 | result /= MyInt(2); 12 | assert(result.0 == 5); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-div1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Div for MyInt { 4 | fn div(rhs: MyInt): MyInt { 5 | MyInt(self.0 / rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(10) / MyInt(2); 11 | assert(result.0 == 5); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-logical-shr1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Shr for MyInt { 4 | fn shr(shift: Int32): MyInt { 5 | MyInt(self.0 >>> shift) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(3) >>> 1i32; 11 | assert(result.0 == 1); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-mod-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(15); 3 | result(0) %= 10; 4 | assert(result(0) == 5); 5 | result(0) %= 3; 6 | assert(result(0) == 2); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-mod-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 10; 3 | result %= 2; 4 | let fct = ||: Int { result }; 5 | assert(result == 0); 6 | assert(fct() == 0); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-mod-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 15); 5 | result.value %= 10; 6 | assert(result.value == 5); 7 | result.value %= 3; 8 | assert(result.value == 2); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-mod-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 15; 2 | 3 | fn main() { 4 | result %= 10; 5 | assert(result == 5); 6 | result %= 3; 7 | assert(result == 2); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-mod-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 15; 3 | result %= 10; 4 | assert(result == 5); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-mod-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Mod for MyInt { 4 | fn modulo(rhs: MyInt): MyInt { 5 | MyInt(self.0 % rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(15); 11 | result %= MyInt(10); 12 | assert(result.0 == 5); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-mod1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Mod for MyInt { 4 | fn modulo(rhs: MyInt): MyInt { 5 | MyInt(self.0 % rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(10) % MyInt(3); 11 | assert(result.0 == 1); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-mul-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(5); 3 | result(0) *= 2; 4 | assert(result(0) == 10); 5 | result(0) *= 3; 6 | assert(result(0) == 30); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-mul-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 5; 3 | result *= 2; 4 | let fct = ||: Int { result }; 5 | assert(result == 10); 6 | assert(fct() == 10); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-mul-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 5); 5 | result.value *= 2; 6 | assert(result.value == 10); 7 | result.value *= 3; 8 | assert(result.value == 30); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-mul-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 5; 2 | 3 | fn main() { 4 | result *= 2; 5 | assert(result == 10); 6 | result *= 3; 7 | assert(result == 30); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-mul-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 5; 3 | result *= 2; 4 | assert(result == 10); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-mul-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Mul for MyInt { 4 | fn mul(rhs: MyInt): MyInt { 5 | MyInt(self.0 * rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(5); 11 | result *= MyInt(2); 12 | assert(result.0 == 10); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-mul-assign-outer-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result = 5; 3 | let fct = || { result *= 2; }; 4 | fct(); 5 | assert(result == 10); 6 | fct(); 7 | assert(result == 20); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-mul1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Mul for MyInt { 4 | fn mul(rhs: MyInt): MyInt { 5 | MyInt(self.0 * rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(5) * MyInt(2); 11 | assert(result.0 == 10); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-neg1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Neg for MyInt { 4 | fn neg(): MyInt { 5 | MyInt(-self.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = -MyInt(7); 11 | assert(result.0 == -7); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-not1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Not for MyInt { 4 | fn not(): MyInt { 5 | MyInt(!self.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = !MyInt(-2); 11 | assert(result.0 == 1); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-sar-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(11); 3 | result(0) >>= 1i32; 4 | assert(result(0) == 5); 5 | result(0) >>= 1i32; 6 | assert(result(0) == 2); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-sar-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 11; 3 | result >>= 1i32; 4 | let fct = ||: Int { result }; 5 | assert(result == 5); 6 | assert(fct() == 5); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-sar-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 11); 5 | result.value >>= 1i32; 6 | assert(result.value == 5); 7 | result.value >>= 1i32; 8 | assert(result.value == 2); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-sar-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 11; 2 | 3 | fn main() { 4 | result >>= 1i32; 5 | assert(result == 5); 6 | result >>= 1i32; 7 | assert(result == 2); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-sar-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 11; 3 | result >>= 1i32; 4 | assert(result == 5); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-sar-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Sar for MyInt { 4 | fn sar(rhs: Int32): MyInt { 5 | MyInt(self.0 >> rhs) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(11); 11 | result >>= 2i32; 12 | assert(result.0 == 2); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-sar-assign-outer-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result = 11; 3 | let fct = || { result >>= 1i32; }; 4 | fct(); 5 | assert(result == 5); 6 | fct(); 7 | assert(result == 2); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-shl-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Array[Int]::new(1); 5 | result(0) <<= 2i32; 6 | assert(result(0) == 4); 7 | result(0) <<= 1i32; 8 | assert(result(0) == 8); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-shl-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 1; 3 | result <<= 2i32; 4 | let fct = ||: Int { result }; 5 | assert(result == 4); 6 | assert(fct() == 4); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-shl-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 1); 5 | result.value <<= 2i32; 6 | assert(result.value == 4); 7 | result.value <<= 1i32; 8 | assert(result.value == 8); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-shl-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 1; 2 | 3 | fn main() { 4 | result <<= 2i32; 5 | assert(result == 4); 6 | result <<= 1i32; 7 | assert(result == 8); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-shl-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 1; 3 | result <<= 2i32; 4 | assert(result == 4); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-shl-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Shl for MyInt { 4 | fn shl(rhs: Int32): MyInt { 5 | MyInt(self.0 << rhs) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(1); 11 | result <<= 2i32; 12 | assert(result.0 == 4); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-shl-assign-outer-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result = 1; 3 | let fct = || { result <<= 1i32; }; 4 | fct(); 5 | assert(result == 2); 6 | fct(); 7 | assert(result == 4); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-shl1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Shl for MyInt { 4 | fn shl(shift: Int32): MyInt { 5 | MyInt(self.0 << shift) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(1) << 1i32; 11 | assert(result.0 == 2); 12 | } 13 | -------------------------------------------------------------------------------- /tests/ops/ops-shr-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(11); 3 | result(0) >>>= 1i32; 4 | assert(result(0) == 5); 5 | result(0) >>>= 1i32; 6 | assert(result(0) == 2); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-shr-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 11; 3 | result >>>= 1i32; 4 | let fct = ||: Int { result }; 5 | assert(result == 5); 6 | assert(fct() == 5); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-shr-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 11); 5 | result.value >>>= 1i32; 6 | assert(result.value == 5); 7 | result.value >>>= 1i32; 8 | assert(result.value == 2); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-shr-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 11; 2 | 3 | fn main() { 4 | result >>>= 1i32; 5 | assert(result == 5); 6 | result >>>= 1i32; 7 | assert(result == 2); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-shr-assign-local-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 11; 3 | result >>= 1i32; 4 | assert(result == 5); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-shr-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Shr for MyInt { 4 | fn shr(rhs: Int32): MyInt { 5 | MyInt(self.0 >>> rhs) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(11); 11 | result >>>= 2i32; 12 | assert(result.0 == 2); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-shr-assign-outer-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result = 11; 3 | let fct = || { result >>>= 1i32; }; 4 | fct(); 5 | assert(result == 5); 6 | fct(); 7 | assert(result == 2); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-sub-array-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = Array[Int]::new(5); 3 | result(0) -= 2; 4 | assert(result(0) == 3); 5 | result(0) -= 2; 6 | assert(result(0) == 1); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-sub-assign-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 5; 3 | result -= 2; 4 | let fct = ||: Int { result }; 5 | assert(result == 3); 6 | assert(fct() == 3); 7 | } 8 | -------------------------------------------------------------------------------- /tests/ops/ops-sub-assign-field-intrinsic.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: Int } 2 | 3 | fn main() { 4 | let result = Foo(value = 5); 5 | result.value -= 2; 6 | assert(result.value == 3); 7 | result.value -= 2; 8 | assert(result.value == 1); 9 | } 10 | -------------------------------------------------------------------------------- /tests/ops/ops-sub-assign-global-intrinsic.dora: -------------------------------------------------------------------------------- 1 | let mut result: Int = 5; 2 | 3 | fn main() { 4 | result -= 2; 5 | assert(result == 3); 6 | result -= 2; 7 | assert(result == 1); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-sub-assign-local-var-assign.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result: Int = 5; 3 | result -= 2; 4 | assert(result == 3); 5 | } 6 | -------------------------------------------------------------------------------- /tests/ops/ops-sub-assign-local-var.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Sub for MyInt { 4 | fn sub(rhs: MyInt): MyInt { 5 | MyInt(self.0 - rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let mut result = MyInt(5); 11 | result -= MyInt(2); 12 | assert(result.0 == 3); 13 | } 14 | -------------------------------------------------------------------------------- /tests/ops/ops-sub-assign-outer-context-var-intrinsic.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut result = 5; 3 | let fct = || { result -= 2; }; 4 | fct(); 5 | assert(result == 3); 6 | fct(); 7 | assert(result == 1); 8 | } 9 | -------------------------------------------------------------------------------- /tests/ops/ops-sub1.dora: -------------------------------------------------------------------------------- 1 | struct MyInt(Int64) 2 | 3 | impl std::traits::Sub for MyInt { 4 | fn sub(rhs: MyInt): MyInt { 5 | MyInt(self.0 - rhs.0) 6 | } 7 | } 8 | 9 | fn main() { 10 | let result = MyInt(5) - MyInt(1); 11 | assert(result.0 == 4); 12 | } 13 | -------------------------------------------------------------------------------- /tests/stacktrace/print-stack-trace1.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc-verify" 2 | //= stdout "main (tests/stacktrace/print-stack-trace1.dora:5:11)\n" 3 | 4 | fn main() { 5 | let e = std::Stacktrace::new(); 6 | e.print(); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/abort1.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | //= stderr "program aborted.\n" 3 | 4 | fn main() { 5 | std::abort(); 6 | } 7 | -------------------------------------------------------------------------------- /tests/stdlib/arg1.dora: -------------------------------------------------------------------------------- 1 | //= args 1 2 3 2 | use std::string::Stringable; 3 | 4 | fn main() { 5 | let val = std::argc().toString(); 6 | println(val); 7 | println(std::argv(0i32)); 8 | println(std::argv(1i32)); 9 | println(std::argv(2i32)); 10 | } 11 | -------------------------------------------------------------------------------- /tests/stdlib/char-len-utf8.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert('a'.lenUtf8() == 1i32); 3 | assert('ü'.lenUtf8() == 2i32); 4 | assert('ß'.lenUtf8() == 2i32); 5 | assert('€'.lenUtf8() == 3i32); 6 | assert('𐍈'.lenUtf8() == 4i32); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/cmp-char.dora: -------------------------------------------------------------------------------- 1 | use std::traits::Ordering; 2 | use std::traits::Comparable; 3 | 4 | fn main() { 5 | assert('a'.cmp('b') == Ordering::Less); 6 | assert('b'.cmp('a') == Ordering::Greater); 7 | assert('a'.cmp('a') == Ordering::Equal); 8 | } 9 | -------------------------------------------------------------------------------- /tests/stdlib/exit0.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | std::exit(0i32); 3 | } -------------------------------------------------------------------------------- /tests/stdlib/exit1.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | std::exit(1i32); 5 | } -------------------------------------------------------------------------------- /tests/stdlib/exit2.dora: -------------------------------------------------------------------------------- 1 | //= error code 2 2 | 3 | fn main() { 4 | std::exit(2i32); 5 | } -------------------------------------------------------------------------------- /tests/stdlib/fatal1.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | std::fatalError[()]("bla"); 5 | } 6 | -------------------------------------------------------------------------------- /tests/stdlib/fatal2.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | std::fatalError[Foo]("bla"); 5 | } 6 | 7 | struct Foo(a: Int64, b: Int64, c: Int64, d: Int64) 8 | -------------------------------------------------------------------------------- /tests/stdlib/hashmap4.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let map = std::HashMap[Int32, String]::new(); 3 | 4 | assert(map.insert(1024i32, "1024").isNone()); 5 | assert(map.insert(2048i32, "2048").isNone()); 6 | 7 | assert(map.remove(1024i32).isSome()); 8 | assert(map.insert(2048i32, "new 2048").isSome()); 9 | } 10 | -------------------------------------------------------------------------------- /tests/stdlib/hashset3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let set = std::HashSet[Int32]::new(1i32, 10_000i32, 7i32); 3 | assert(set.size() == 3i64); 4 | assert(set.contains(1i32)); 5 | assert(set.contains(10_000i32)); 6 | assert(set.contains(7i32)); 7 | assert(!set.contains(0i32)); 8 | } 9 | -------------------------------------------------------------------------------- /tests/stdlib/hex1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(0xFFi32 == 255i32); 3 | assert(0x10i32 == 16i32); 4 | 5 | assert(0xFFi64 == 255i64); 6 | assert(0x10i64 == 16i64); 7 | 8 | assert(0xFFu8 == 255u8); 9 | assert(0x10u8 == 16u8); 10 | } 11 | -------------------------------------------------------------------------------- /tests/stdlib/int-alias.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(Int::maxValue() == Int64::maxValue()); 3 | assert(Int::minValue() == Int64::minValue()); 4 | 5 | let x: Int = -10; 6 | assert(x.abs() == 10); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/iterator-fold.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Vec[Int]::new(1, 2, 3, 4, 5).iter().fold[Int](0, |result: Int, x: Int|: Int { result + x }); 3 | assert(x == 15); 4 | 5 | let x = Array[Int]::new(1, 2, 3, 4, 5).iter().fold[Int](0, |result: Int, x: Int|: Int { result + x }); 6 | assert(x == 15); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/iterator-join.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Vec[Int]::new(1, 2, 3, 4, 5).iter().join(","); 3 | assert(x == "1,2,3,4,5"); 4 | 5 | let x = Array[Int]::new(1, 2, 3, 4, 5).iter().join(":"); 6 | assert(x == "1:2:3:4:5"); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/iterator-reduce.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Vec[Int]::new(1, 2, 3, 4, 5).iter().reduce(|result: Int, x: Int|: Int { result + x }); 3 | assert(x == Some[Int](15)); 4 | 5 | let x = Array[Int]::new(1, 2, 3, 4, 5).iter().reduce(|result: Int, x: Int|: Int { result + x }); 6 | assert(x == Some[Int](15)); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/limit1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(-2147483648i32 == Int32::minValue()); 3 | assert(2147483647i32 == Int32::maxValue()); 4 | 5 | assert(-9223372036854775808i64 == Int64::minValue()); 6 | assert(9223372036854775807i64 == Int64::maxValue()); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/option-getOrZero.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let some = Option[Int32]::Some(23i32); 3 | let none = Option[Int32]::None; 4 | 5 | // thread 'main' panicked at 'no impl found for generic trait method call', dora/src/vm/impls.rs:86:10 6 | // assert(some.getOrZero() == 23i32); 7 | // assert(none.getOrZero() == 0i32); 8 | } 9 | -------------------------------------------------------------------------------- /tests/stdlib/option1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Option[Int32]::None; 3 | assert(2i32 == x.unwrapOr(2i32)); 4 | 5 | let x = Option[Int32]::Some(2i32); 6 | assert(2i32 == x.unwrapOr(100i32)); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/parse1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert("1".toInt32().getOrPanic() == 1i32); 3 | assert("100".toInt32().getOrPanic() == 100i32); 4 | assert("789".toInt32().getOrPanic() == 789i32); 5 | assert("bla".toInt32().isNone()); 6 | } 7 | -------------------------------------------------------------------------------- /tests/stdlib/queue2.dora: -------------------------------------------------------------------------------- 1 | use std::Queue; 2 | 3 | fn main() { 4 | let q = Queue[Int32]::new(); 5 | 6 | for i in std::range(0, 100) { 7 | q.enqueue(i.toInt32()); 8 | } 9 | 10 | for i in std::range(0, 100) { 11 | assert(q.dequeue() == i.toInt32()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/stdlib/rand1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let rnd = std::Random::new(0); 3 | 4 | assert(rnd.nextInt32() == -1155484576i32); 5 | assert(rnd.nextInt32() == -723955400i32); 6 | assert(rnd.nextInt32() == 1033096058i32); 7 | assert(rnd.nextInt32() == -1690734402i32); 8 | } 9 | -------------------------------------------------------------------------------- /tests/stdlib/result-getErrOrDefault.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let ok = Result[Int32, String]::Ok(23i32); 3 | let er = Result[Int32, String]::Err("err"); 4 | 5 | assert(ok.getErrOrDefault() == ""); 6 | assert(er.getErrOrDefault() == "err"); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/result-getErrOrZero.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let ok = Result[String, Int32]::Ok("ok"); 3 | let er = Result[String, Int32]::Err(23i32); 4 | 5 | // thread 'main' panicked at 'no impl found for generic trait method call', dora/src/vm/impls.rs:86:10 6 | // assert(ok.getErrOrZero() == 23i32); 7 | // assert(er.getErrOrZero() == 0i32); 8 | } 9 | -------------------------------------------------------------------------------- /tests/stdlib/result-getOrDefault.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let ok = Result[Int32, String]::Ok(23i32); 3 | let er = Result[Int32, String]::Err("err"); 4 | 5 | assert(ok.getOrDefault() == 23i32); 6 | assert(er.getOrDefault() == 0i32); 7 | } 8 | -------------------------------------------------------------------------------- /tests/stdlib/result-getOrZero.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let ok = Result[Int32, String]::Ok(23i32); 3 | let er = Result[Int32, String]::Err("err"); 4 | 5 | // thread 'main' panicked at 'no impl found for generic trait method call', dora/src/vm/impls.rs:86:10 6 | // assert(ok.getOrZero() == 23i32); 7 | // assert(er.getOrZero() == 0i32); 8 | } 9 | -------------------------------------------------------------------------------- /tests/stdlib/result-isErr.dora: -------------------------------------------------------------------------------- 1 | use std::traits::Not; 2 | 3 | fn main() { 4 | assert(Result[Int32, String]::Ok(23i32).isErr().not()); 5 | assert(Result[Int32, String]::Err("err").isErr()); 6 | } 7 | -------------------------------------------------------------------------------- /tests/stdlib/result-isOk.dora: -------------------------------------------------------------------------------- 1 | use std::traits::Not; 2 | 3 | fn main() { 4 | assert(Result[Int32, String]::Ok(23i32).isOk()); 5 | assert(Result[Int32, String]::Err("err").isOk().not()); 6 | } 7 | -------------------------------------------------------------------------------- /tests/stdlib/sleep1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | std::sleep(1i32); 3 | } 4 | -------------------------------------------------------------------------------- /tests/stdlib/unreachable1.dora: -------------------------------------------------------------------------------- 1 | //= error code 1 2 | 3 | fn main() { 4 | unreachable[()]() 5 | } 6 | -------------------------------------------------------------------------------- /tests/stdlib/vec-sort.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let vec = Vec[Int32]::new(); 3 | vec.push(0i32); 4 | vec.push(9i32); 5 | vec.push(1i32); 6 | vec.sort(); 7 | assert(vec == Vec[Int32]::new(0i32, 1i32, 9i32)); 8 | } -------------------------------------------------------------------------------- /tests/string/concat1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = "hello " + "world"; 3 | assert(x.size() == 11i64); 4 | } 5 | -------------------------------------------------------------------------------- /tests/string/string-clone.dora: -------------------------------------------------------------------------------- 1 | //= stdout "abc\n" 2 | 3 | fn main() { 4 | let x = "abc"; 5 | let y = x.clone(); 6 | 7 | assert(x == y); 8 | assert(x !== y); 9 | 10 | println(y); 11 | } -------------------------------------------------------------------------------- /tests/string/string-concat.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(eq("a")); 3 | assert(!eq("aa")); 4 | } 5 | 6 | fn eq(a: String): Bool { 7 | return "ab" == a + "b"; 8 | } 9 | -------------------------------------------------------------------------------- /tests/string/string-getByte.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = "ABC"; 3 | 4 | assert(x.getByte(0i64) == 65u8); 5 | assert(x.getByte(1i64) == 66u8); 6 | assert(x.getByte(2i64) == 67u8); 7 | } 8 | -------------------------------------------------------------------------------- /tests/string/string-length.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert("abc".size() == 3i64); 3 | 4 | let x = "abcdef"; 5 | assert(x.size() == 6i64); 6 | } 7 | -------------------------------------------------------------------------------- /tests/string/string-toString.dora: -------------------------------------------------------------------------------- 1 | use std::string::Stringable; 2 | 3 | fn main() { 4 | assert(true.toString() == "true"); 5 | assert(false.toString() == "false"); 6 | assert(0i32.toString() == "0"); 7 | assert("toString".toString() == "toString"); 8 | } 9 | -------------------------------------------------------------------------------- /tests/string/stringable.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | str[Bool](true); 3 | str[Bool](false); 4 | str[UInt8](1.toUInt8()); 5 | str[Int32](1i32); 6 | str[Int64](1i64); 7 | str[Float32](1f32); 8 | str[Float64](1f64); 9 | } 10 | 11 | fn str[T : std::Stringable](val: T): String { 12 | val.toString() 13 | } 14 | -------------------------------------------------------------------------------- /tests/string/template2.dora: -------------------------------------------------------------------------------- 1 | fn stringify[T: std::Stringable](t: T): String { 2 | return "${t}"; 3 | } 4 | 5 | fn main() { 6 | assert(stringify[Int32](1i32) == "1"); 7 | assert(stringify[Float32](1.0f32) == "1"); 8 | assert(stringify[Float64](0.2) == "0.2"); 9 | } -------------------------------------------------------------------------------- /tests/struct/struct-array2.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | 3 | struct Foo { f1: Int32, f2: Int32 } 4 | 5 | fn main() { 6 | let arr = Array[Foo]::fill(7i64, Foo(f1 = 10i32, f2 = 17i32)); 7 | let y: Foo = arr(10i64); 8 | } 9 | -------------------------------------------------------------------------------- /tests/struct/struct-array3.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | 3 | struct Foo { f1: Int32, f2: Int32 } 4 | 5 | fn main() { 6 | let arr = Array[Foo]::fill(7i64, Foo(f1 = 10i32, f2 = 17i32)); 7 | arr(10i64) = Foo(f1 = 100i32, f2 = 170i32); 8 | } 9 | -------------------------------------------------------------------------------- /tests/struct/struct-load.dora: -------------------------------------------------------------------------------- 1 | struct Foo { f1: Int32, f2: Bool } 2 | 3 | fn f(): Int32 { 4 | let x = Foo(f1 = 10i32, f2 = false); 5 | x.f1 6 | } 7 | 8 | fn g(): Bool { 9 | let x = Foo(f1 = 10i32, f2 = false); 10 | x.f2 11 | } 12 | 13 | fn main() { 14 | assert(f() == 10i32); 15 | assert(!g()); 16 | } 17 | -------------------------------------------------------------------------------- /tests/struct/struct-move.dora: -------------------------------------------------------------------------------- 1 | struct Foo { f1: Int32, f2: Bool } 2 | 3 | fn f(): Foo { 4 | let x = Foo(f1 = 10i32, f2 = false); 5 | let y = x; 6 | y 7 | } 8 | 9 | fn main() { 10 | f(); 11 | } 12 | -------------------------------------------------------------------------------- /tests/struct/struct-named-pattern1.dora: -------------------------------------------------------------------------------- 1 | struct Foo { a: Int, b: Int } 2 | 3 | fn get_a1(x: Foo): Int { 4 | let Foo(a, b) = x; 5 | a 6 | } 7 | 8 | fn get_a2(x: Foo): Int { 9 | let Foo(b, a) = x; 10 | a 11 | } 12 | 13 | fn main() { 14 | let x = Foo(a=10, b=23); 15 | assert(get_a1(x) == get_a2(x)); 16 | } -------------------------------------------------------------------------------- /tests/struct/struct-new.dora: -------------------------------------------------------------------------------- 1 | struct Foo { f1: Int32, f2: Bool } 2 | 3 | fn f(): Foo { 4 | Foo(f1 = 10i32, f2 = false) 5 | } 6 | 7 | fn main() { 8 | f(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/swiper/large5.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=swiper --gc-verify --max-heap-size=32M" 2 | //= error oom 3 | 4 | fn main() { 5 | let mut x = Vec[Array[Int32]]::new(); 6 | let mut i = 0i32; 7 | 8 | while i < 100_000i32 { 9 | x.push(Array[Int32]::zero(32i64 * 1024i64)); 10 | i = i + 1i32; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/swiper/marking3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | std::forceCollect(); 3 | std::forceCollect(); 4 | std::forceCollect(); 5 | std::forceCollect(); 6 | std::forceCollect(); 7 | } 8 | -------------------------------------------------------------------------------- /tests/swiper/objarray3.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=swiper --gc-verify" 2 | 3 | fn main() { 4 | let a = Array[Foo]::fill(16i64 * 1024i64, Foo()); 5 | a(16i64 * 1024i64 - 1i64) = Foo(); 6 | std::forceCollect(); 7 | } 8 | 9 | class Foo 10 | -------------------------------------------------------------------------------- /tests/swiper/perm1.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=swiper --gc-verify" 2 | 3 | fn main() { 4 | let x = "perm"; 5 | std::forceMinorCollect(); 6 | assert(x.size() == 4i64); 7 | } 8 | -------------------------------------------------------------------------------- /tests/swiper/promote1.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=swiper --gc-verify" 2 | 3 | fn main() { 4 | let x = Foo(1i32); 5 | std::forceMinorCollect(); 6 | std::forceMinorCollect(); 7 | assert(x.a == 1i32); 8 | } 9 | 10 | class Foo { a: Int32 } 11 | -------------------------------------------------------------------------------- /tests/thread/join1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "one\ntwo\n" 2 | 3 | fn main() { 4 | let thread = std::thread::spawn(|| { 5 | std::sleep(2i32); 6 | println("one"); 7 | }); 8 | thread.join(); 9 | println("two"); 10 | } 11 | -------------------------------------------------------------------------------- /tests/thread/join2-swiper-compact.dora: -------------------------------------------------------------------------------- 1 | //= file "tests/thread/join2-copy.dora" 2 | //= vm-args "--gc=swiper --gc-verify --gc-verbose" 3 | //= flaky 4 | -------------------------------------------------------------------------------- /tests/thread/join2-swiper-minor.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=swiper" 2 | 3 | fn main() { 4 | let mut i = 0i32; 5 | 6 | while i < 10_000i32 { 7 | std::thread::spawn(|| {}); 8 | 9 | if i % 1_000i32 == 0i32 { 10 | std::forceMinorCollect(); 11 | } 12 | 13 | i = i + 1i32; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/thread/join3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let thread = std::thread::spawn(|| { 3 | std::sleep(1i32); 4 | std::forceCollect(); 5 | }); 6 | thread.join(); 7 | } 8 | -------------------------------------------------------------------------------- /tests/thread/native1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | std::thread::spawn(|| { 3 | nativeCalls(); 4 | }); 5 | 6 | nativeCalls(); 7 | } 8 | 9 | fn nativeCalls() { 10 | let mut i = 0i32; 11 | 12 | while i < 100_000i32 { 13 | std::sleep(0i32); 14 | i = i + 1i32; 15 | } 16 | } -------------------------------------------------------------------------------- /tests/thread/spawn1.dora: -------------------------------------------------------------------------------- 1 | //= stdout "one\ntwo\n" 2 | 3 | fn main() { 4 | std::thread::spawn(|| { 5 | println("one") 6 | }).join(); 7 | 8 | println("two"); 9 | } 10 | -------------------------------------------------------------------------------- /tests/thread/thread-current-main.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let thread = std::Thread::current(); 3 | assert(thread.id() == 1); 4 | } 5 | -------------------------------------------------------------------------------- /tests/thread/thread-unlock-fail.dora: -------------------------------------------------------------------------------- 1 | //= error assert 2 | 3 | fn main() { 4 | let mtx = std::Mutex::new(); 5 | let cv = std::Condition::new(); 6 | 7 | mtx.lock[()](|| { 8 | let thread = std::thread::spawn(|| { 9 | cv.wait(mtx); 10 | }); 11 | 12 | thread.join(); 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /tests/trait/super-trait-operator-overloading1.dora: -------------------------------------------------------------------------------- 1 | trait A: std::Equals {} 2 | 3 | impl A for Int64 {} 4 | 5 | fn f[T: A](lhs: T, rhs: T): Bool { 6 | lhs == rhs 7 | } 8 | 9 | fn main() { 10 | assert(f[Int64](2, 2)); 11 | } 12 | -------------------------------------------------------------------------------- /tests/trait/trait-assoc-class-named.dora: -------------------------------------------------------------------------------- 1 | trait Trait1 { 2 | type X; 3 | } 4 | 5 | class Foo[T: Trait1] { 6 | a: T, 7 | b: T::X 8 | } 9 | 10 | impl Trait1 for Int { 11 | type X = String; 12 | } 13 | 14 | fn main() { 15 | let foo = Foo[Int](a = 1, b = "bar"); 16 | assert(foo.a == 1); 17 | assert(foo.b == "bar"); 18 | } 19 | -------------------------------------------------------------------------------- /tests/trait/trait-assoc-class-unnamed.dora: -------------------------------------------------------------------------------- 1 | trait Trait1 { 2 | type X; 3 | } 4 | 5 | class Foo[T: Trait1](T, T::X) 6 | 7 | impl Trait1 for Int { 8 | type X = String; 9 | } 10 | 11 | fn main() { 12 | let foo = Foo[Int](1, "bar"); 13 | assert(foo.0 == 1); 14 | assert(foo.1 == "bar"); 15 | } 16 | -------------------------------------------------------------------------------- /tests/trait/trait-assoc-struct-named.dora: -------------------------------------------------------------------------------- 1 | trait Trait1 { 2 | type X; 3 | } 4 | 5 | struct Foo[T: Trait1] { 6 | a: T, 7 | b: T::X 8 | } 9 | 10 | impl Trait1 for Int { 11 | type X = String; 12 | } 13 | 14 | fn main() { 15 | let foo = Foo[Int](a = 1, b = "bar"); 16 | assert(foo.a == 1); 17 | assert(foo.b == "bar"); 18 | } 19 | -------------------------------------------------------------------------------- /tests/trait/trait-assoc-struct-unnamed.dora: -------------------------------------------------------------------------------- 1 | trait Trait1 { 2 | type X; 3 | } 4 | 5 | struct Foo[T: Trait1](T, T::X) 6 | 7 | impl Trait1 for Int { 8 | type X = String; 9 | } 10 | 11 | fn main() { 12 | let foo = Foo[Int](1, "bar"); 13 | assert(foo.0 == 1); 14 | assert(foo.1 == "bar"); 15 | } 16 | -------------------------------------------------------------------------------- /tests/trait/trait-object-ignore1.dora: -------------------------------------------------------------------------------- 1 | trait Foo { 2 | fn one(): Int { 1 } 3 | @TraitObjectIgnore 4 | fn two(): Int { 2 } 5 | fn three(): Int { 3 } 6 | } 7 | 8 | impl Foo for Int {} 9 | 10 | fn main() { 11 | let x = 1 as Foo; 12 | assert(x.one() == 1); 13 | assert(x.three() == 3); 14 | } 15 | -------------------------------------------------------------------------------- /tests/trait/trait-object1.dora: -------------------------------------------------------------------------------- 1 | trait Foo { fn test(); } 2 | 3 | class Baz 4 | 5 | impl Foo for Baz { 6 | fn test() {} 7 | } 8 | 9 | fn main() { 10 | let f = foo(); 11 | } 12 | 13 | fn foo(): Foo { 14 | Baz() as Foo 15 | } 16 | -------------------------------------------------------------------------------- /tests/tuple/tuple-array1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let arr = Array[(Int32, Int64)]::fill(10i64, (0i32, 0i64)); 3 | assert(arr.size() == 10i64); 4 | let arr = Array[(Int32, Int64)]::fill(0i64, (0i32, 0i64)); 5 | assert(arr.size() == 0i64); 6 | } 7 | -------------------------------------------------------------------------------- /tests/tuple/tuple-array2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let arr = Array[(Int32, Int64)]::fill(10i64, (0i32, 0i64)); 3 | assert(arr.size() == 10i64); 4 | let x: (Int32, Int64) = arr(6i64); 5 | assert(x.0 == 0i32 && x.1 == 0i64); 6 | } 7 | -------------------------------------------------------------------------------- /tests/tuple/tuple-array3.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | 3 | fn main() { 4 | let x = Array[(Int32, Int64)]::fill(7i64, (0i32, 0i64)); 5 | let y: (Int32, Int64) = x(10i64); 6 | } 7 | -------------------------------------------------------------------------------- /tests/tuple/tuple-array4.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | 3 | fn main() { 4 | let x = Array[(Int32, Int64)]::fill(7i64, (0i32, 0i64)); 5 | x(10i64) = (12i32, 4711i64); 6 | } 7 | -------------------------------------------------------------------------------- /tests/tuple/tuple-extension1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(f((3, 4)) == 7); 3 | assert(f((-3, 4)) == 1); 4 | assert(f((3, -4)) == -1); 5 | } 6 | 7 | impl (Int64, Int64) { 8 | fn f(): Int64 { 9 | self.0 + self.1 10 | } 11 | } 12 | 13 | fn f(x: (Int64, Int64)): Int64 { 14 | x.f() 15 | } 16 | -------------------------------------------------------------------------------- /tests/tuple/tuple-gc1.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=copy --disable-tlab --gc-stress" 2 | 3 | class Foo { value: Int32 } 4 | 5 | fn main() { 6 | let tpl: (Foo) = if false { 7 | (createFoo(),) 8 | } else { 9 | std::forceCollect(); 10 | (createFoo(),) 11 | }; 12 | } 13 | 14 | fn createFoo(): Foo { Foo(1i32) } 15 | -------------------------------------------------------------------------------- /tests/tuple/tuple-global-gc1.dora: -------------------------------------------------------------------------------- 1 | let mut x: (String, Bool) = ("", false); 2 | 3 | fn main() { 4 | std::forceCollect(); 5 | x = ("my string", true); 6 | std::forceCollect(); 7 | assert(x.0 == "my string"); 8 | assert(x.1); 9 | } 10 | -------------------------------------------------------------------------------- /tests/tuple/tuple-local-assign.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut x = ("my string", true); 3 | let mut y = ("another string", false); 4 | let mut tmp = x; 5 | x = y; 6 | y = tmp; 7 | assert(y.0 == "my string"); 8 | assert(y.1); 9 | assert(x.0 == "another string"); 10 | assert(!x.1); 11 | } 12 | -------------------------------------------------------------------------------- /tests/tuple/tuple-nested1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = (1i32, 2i32, (3i32, 4i32)); 3 | assert(x.0 == 1i32); 4 | assert(x.1 == 2i32); 5 | assert((x.2).0 == 3i32); 6 | assert((x.2).1 == 4i32); 7 | } 8 | -------------------------------------------------------------------------------- /tests/tuple/tuple-nested2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let y = (1i32, ()); 3 | assert(y.0 == 1i32); 4 | let z = y.1; 5 | } 6 | -------------------------------------------------------------------------------- /tests/tuple/tuple-nested3.dora: -------------------------------------------------------------------------------- 1 | class Foo { value: (Int32, Int32, (Int32, Int32)) } 2 | 3 | fn main() { 4 | let x = (1i32, 2i32, (3i32, 4i32)); 5 | let foo = Foo(x); 6 | foo.value = (10i32, 11i32, (12i32, 13i32)); 7 | } 8 | -------------------------------------------------------------------------------- /tests/tuple/tuple-struct1.dora: -------------------------------------------------------------------------------- 1 | struct Pair { x: Int32, y: Int32 } 2 | 3 | fn main() { 4 | let (p1, p2) = f(); 5 | assert((p1.x + p1.y) * (p2.x + p2.y) == 18i32); 6 | } 7 | 8 | fn f(): (Pair, Pair) { 9 | (Pair(x = 1i32, y = 2i32), Pair(x = 5i32, y = 1i32)) 10 | } 11 | -------------------------------------------------------------------------------- /tests/tuple/tuple-template1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result = tpl[String]("test"); 3 | assert(result.0 == "test"); 4 | assert(result.1); 5 | } 6 | 7 | fn tpl[T](value: T): (T, Bool) { 8 | (value, true) 9 | } 10 | -------------------------------------------------------------------------------- /tests/tuple/tuple-template2.dora: -------------------------------------------------------------------------------- 1 | //= vm-args "--gc=copy --disable-tlab --gc-stress" 2 | 3 | fn main() { 4 | let x = id[(String, Foo)](("f" + "o" + "o", Foo(17i32))); 5 | std::forceCollect(); 6 | assert(x.0 == "foo"); 7 | assert(x.1.value == 17i32); 8 | } 9 | 10 | class Foo { value: Int32 } 11 | 12 | fn id[T](x: T): T { x } 13 | -------------------------------------------------------------------------------- /tests/unit/unit-array1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Array[()]::fill(7i64, ()); 3 | assert(x.size() == 7i64); 4 | let y = Array[()]::new(); 5 | assert(y.size() == 0i64); 6 | } 7 | -------------------------------------------------------------------------------- /tests/unit/unit-array2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Array[()]::fill(7i64, ()); 3 | assert(x.size() == 7i64); 4 | let y: () = x(0i64); 5 | x(5i64) = (); 6 | } 7 | -------------------------------------------------------------------------------- /tests/unit/unit-array3.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | 3 | fn main() { 4 | let x = Array[()]::fill(7i64, ()); 5 | let y: () = x(10i64); 6 | } -------------------------------------------------------------------------------- /tests/unit/unit-array4.dora: -------------------------------------------------------------------------------- 1 | //= error array 2 | 3 | fn main() { 4 | let x = Array[()]::fill(7i64, ()); 5 | x(10i64) = (); 6 | } -------------------------------------------------------------------------------- /tests/unit/unit-array5.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Array[()]::fill(7i64, ()); 3 | } -------------------------------------------------------------------------------- /tests/unit/unit-for1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut sum = 0i64; 3 | for x in Array[()]::fill(100i64, ()) { 4 | sum = sum + 1i64; 5 | } 6 | assert(sum == 100i64); 7 | } 8 | -------------------------------------------------------------------------------- /tests/unit/unit-for2.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut sum = 0i64; 3 | for x in Vec[()]::new((), (), (), ()) { 4 | sum = sum + 1i64; 5 | } 6 | assert(sum == 4i64); 7 | } 8 | -------------------------------------------------------------------------------- /tests/unit/unit-global.dora: -------------------------------------------------------------------------------- 1 | let mut x: () = (); 2 | 3 | fn main() { 4 | x = (); 5 | foo(); 6 | } 7 | 8 | fn foo(): () { 9 | x 10 | } -------------------------------------------------------------------------------- /tests/unit/unit-param.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = foo(()); 3 | foo(x); 4 | } 5 | 6 | fn foo(x: ()): () { 7 | x 8 | } 9 | -------------------------------------------------------------------------------- /tests/unit/unit-struct1.dora: -------------------------------------------------------------------------------- 1 | struct A(()) 2 | 3 | fn main() { 4 | let a = A(()); 5 | let x: () = foo(a); 6 | 7 | let b1 = B[()](()); 8 | let b2 = bar[()](()); 9 | } 10 | 11 | fn foo(a: A): () { a.0 } 12 | 13 | fn bar[T](value: T): B[T] { 14 | B[T](value) 15 | } 16 | 17 | struct B[T](T) 18 | -------------------------------------------------------------------------------- /tests/unit/unit-template1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let result: () = tpl[()](()); 3 | } 4 | 5 | fn tpl[T](value: T): T { 6 | value 7 | } 8 | -------------------------------------------------------------------------------- /tests/unit/unit-var.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut x = (); 3 | let mut y: () = (); 4 | y = (); 5 | x = y; 6 | } -------------------------------------------------------------------------------- /tests/unit/unit-vec1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let data = Vec[()]::new(); 3 | assert(data.size() == 0i64); 4 | 5 | let data = Vec[()]::new((), (), ()); 6 | assert(data.size() == 3i64); 7 | } 8 | -------------------------------------------------------------------------------- /tests/vec/vec-field2.dora: -------------------------------------------------------------------------------- 1 | class Foo { 2 | vec: Vec[Int32], 3 | } 4 | 5 | fn main() { 6 | let foo = Foo(Vec[Int32]::new(1i32, 2i32, 3i32)); 7 | assert(foo.vec(0i64) == 1i32); 8 | } 9 | -------------------------------------------------------------------------------- /tests/vec/vec-toString.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | assert(Vec[Int32]::new().toString() == "Vec()"); 3 | assert(Vec[Int32]::new(1i32).toString() == "Vec(1)"); 4 | assert(Vec[Int32]::new(1i32, 2i32, 3i32).toString() == "Vec(1, 2, 3)"); 5 | } 6 | -------------------------------------------------------------------------------- /tests/vec/vec1.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Vec[Int32]::new(); 3 | x.push(1i32); 4 | x.push(2i32); 5 | x.push(3i32); 6 | 7 | assert(x.pop().getOrPanic() == 3i32); 8 | assert(x.pop().getOrPanic() == 2i32); 9 | assert(x.pop().getOrPanic() == 1i32); 10 | } 11 | -------------------------------------------------------------------------------- /tests/vec/vec3.dora: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Vec[Int32]::new(1i32, 2i32, 3i32); 3 | assert(x.size() == 3i64); 4 | assert(x.pop().getOrPanic() == 3i32); 5 | assert(x.pop().getOrPanic() == 2i32); 6 | assert(x.pop().getOrPanic() == 1i32); 7 | } 8 | -------------------------------------------------------------------------------- /tests/whiteboard/sieve.stdout: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 5 4 | 7 5 | 11 6 | 13 7 | 17 8 | 19 9 | 23 10 | 29 11 | 31 12 | 37 13 | 41 14 | 43 15 | 47 16 | 53 17 | 59 18 | 61 19 | 67 20 | 71 21 | 73 22 | 79 23 | 83 24 | 89 25 | 97 26 | -------------------------------------------------------------------------------- /tools/build-arm64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd dora && cargo check --target=aarch64-unknown-linux-gnu --no-default-features 4 | -------------------------------------------------------------------------------- /tools/gc-bench: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | cargo build --release 5 | perf stat -r3 --null target/release/dora --max-heap-size=512M bench/binarytrees/binarytrees.dora 21 2>&1 >/dev/null | grep "seconds time elapsed" | grep -Eo "[0-9]+[.,][0-9]+" | head -1 6 | 7 | -------------------------------------------------------------------------------- /tools/run-with-boots: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cargo run -p dora -- --package boots dora-boots/boots.dora $@ 4 | 5 | if [[ $(uname) == "Darwin" ]]; then 6 | cargo run -p dora --target x86_64-apple-darwin -- --package boots dora-boots/boots.dora $@ 7 | fi 8 | -------------------------------------------------------------------------------- /tools/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cargo build 6 | cargo test 7 | cargo run -p dora -- --boots --report-all-warnings --emit-compiler --bootstrap-compiler tests/boots/hello.dora 8 | ruby tools/tester.rb $@ 9 | cargo run -p dora -- test --boots --test-boots --gc-verify tests/hello-world.dora 10 | -------------------------------------------------------------------------------- /tools/test-3stage-bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cargo run -p dora -- --boots --emit-compiler --bootstrap-compiler tests/boots/hello.dora 6 | -------------------------------------------------------------------------------- /tools/test-3stage-bootstrap-mac-x64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | TARGET=x86_64-apple-darwin 6 | cargo run -p dora --target $TARGET -- --boots --emit-compiler --bootstrap-compiler tests/boots/hello.dora 7 | -------------------------------------------------------------------------------- /tools/test-boots: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cargo run -p dora -- test --boots --report-all-warnings --test-boots --gc-verify tests/hello-world.dora 6 | cargo run -p dora -- --boots --emit-compiler --bootstrap-compiler tests/boots/hello.dora 7 | ruby tools/tester.rb tests/boots 8 | -------------------------------------------------------------------------------- /tools/test-boots-mac-x64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | TARGET=x86_64-apple-darwin 6 | cargo run -p dora --target $TARGET -- test --boots --test-boots --gc-verify tests/hello-world.dora 7 | cargo run -p dora --target $TARGET -- --boots --emit-compiler --bootstrap-compiler tests/boots/hello.dora 8 | ruby tools/tester.rb --target $TARGET tests/boots 9 | -------------------------------------------------------------------------------- /tools/test-mac-x64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | TARGET=x86_64-apple-darwin 6 | 7 | cargo build --target $TARGET 8 | cargo test --target $TARGET 9 | ruby tools/tester.rb --target $TARGET $@ 10 | cargo run -p dora --target $TARGET -- test --boots --test-boots --gc-verify tests/hello-world.dora 11 | -------------------------------------------------------------------------------- /tools/test-release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cargo build --release 6 | cargo test --release 7 | cargo run -p dora --release -- --boots --report-all-warnings --emit-compiler --bootstrap-compiler tests/boots/hello.dora 8 | ruby tools/tester.rb --release $@ 9 | cargo run --release -p dora -- test --boots --test-boots tests/hello-world.dora 10 | --------------------------------------------------------------------------------