├── .github └── workflows │ └── .githubCI.yml ├── .gitignore ├── .travis.sh ├── .travis.yml ├── AUTHORS ├── CHANGELOG.md ├── LICENSE ├── README.md ├── doc ├── error-handling.txt ├── implicit fields.txt ├── instruction counts.txt ├── notes │ ├── import syntax.md │ └── re-entrancy.md ├── receiver-less calls 2.txt ├── receiver-less calls.txt ├── rfc │ └── 0001-smarter-imports.md └── site │ ├── blog │ ├── 0-hello-wren.markdown │ ├── 1-0.2.0-and-beyond.markdown │ ├── 2-0.3.0-released.markdown │ ├── 3-0.4.0-released.markdown │ ├── index.markdown │ ├── rss.xml │ └── template.html │ ├── classes.markdown │ ├── cli │ ├── index.markdown │ ├── modules │ │ ├── index.markdown │ │ ├── io │ │ │ ├── directory.markdown │ │ │ ├── file-flags.markdown │ │ │ ├── file.markdown │ │ │ ├── index.markdown │ │ │ ├── stat.markdown │ │ │ ├── stdin.markdown │ │ │ ├── stdout.markdown │ │ │ └── template.html │ │ ├── os │ │ │ ├── index.markdown │ │ │ ├── platform.markdown │ │ │ ├── process.markdown │ │ │ └── template.html │ │ ├── scheduler │ │ │ ├── index.markdown │ │ │ ├── scheduler.markdown │ │ │ └── template.html │ │ ├── template.html │ │ └── timer │ │ │ ├── index.markdown │ │ │ ├── template.html │ │ │ └── timer.markdown │ ├── template.html │ └── usage.markdown │ ├── concurrency.markdown │ ├── contributing.markdown │ ├── control-flow.markdown │ ├── embedding │ ├── calling-c-from-wren.markdown │ ├── calling-wren-from-c.markdown │ ├── configuring-the-vm.markdown │ ├── index.markdown │ ├── slots-and-handles.markdown │ ├── storing-c-data.markdown │ └── template.html │ ├── error-handling.markdown │ ├── functions.markdown │ ├── getting-started.markdown │ ├── index.markdown │ ├── lists.markdown │ ├── maps.markdown │ ├── method-calls.markdown │ ├── modularity.markdown │ ├── modules │ ├── core │ │ ├── bool.markdown │ │ ├── class.markdown │ │ ├── fiber.markdown │ │ ├── fn.markdown │ │ ├── index.markdown │ │ ├── list.markdown │ │ ├── map.markdown │ │ ├── null.markdown │ │ ├── num.markdown │ │ ├── object.markdown │ │ ├── range.markdown │ │ ├── sequence.markdown │ │ ├── string.markdown │ │ ├── system.markdown │ │ └── template.html │ ├── index.markdown │ ├── meta │ │ ├── index.markdown │ │ ├── meta.markdown │ │ └── template.html │ ├── random │ │ ├── index.markdown │ │ ├── random.markdown │ │ └── template.html │ └── template.html │ ├── performance.markdown │ ├── qa.markdown │ ├── static │ ├── codejar-linenumbers.js │ ├── codejar.js │ ├── lzstring.min.js │ ├── prism.css │ ├── prism.js │ ├── style.css │ ├── wren.js │ ├── wren.svg │ ├── wren_try.js │ └── wren_try.wasm │ ├── syntax.markdown │ ├── template.html │ ├── try │ ├── index.markdown │ └── template.html │ ├── values.markdown │ └── variables.markdown ├── example ├── embedding │ └── main.c ├── hello.wren ├── import_module │ ├── cthulu.wren │ └── lovecraft.wren ├── mandelbrot.wren ├── skynet.wren └── syntax.wren ├── projects ├── make.bsd │ ├── Makefile │ ├── wren.make │ ├── wren_shared.make │ └── wren_test.make ├── make.mac │ ├── Makefile │ ├── wren.make │ ├── wren_shared.make │ └── wren_test.make ├── make │ ├── Makefile │ ├── wren.make │ ├── wren_shared.make │ └── wren_test.make ├── premake │ ├── premake5.exe │ └── premake5.lua ├── vs2017 │ ├── wren.sln │ ├── wren.vcxproj │ ├── wren.vcxproj.filters │ ├── wren_shared.vcxproj │ ├── wren_shared.vcxproj.filters │ ├── wren_test.vcxproj │ └── wren_test.vcxproj.filters ├── vs2019 │ ├── wren.sln │ ├── wren.vcxproj │ ├── wren.vcxproj.filters │ ├── wren_shared.vcxproj │ ├── wren_shared.vcxproj.filters │ ├── wren_test.vcxproj │ └── wren_test.vcxproj.filters └── xcode │ ├── wren.xcodeproj │ └── project.pbxproj │ ├── wren.xcworkspace │ └── contents.xcworkspacedata │ ├── wren_shared.xcodeproj │ └── project.pbxproj │ └── wren_test.xcodeproj │ └── project.pbxproj ├── src ├── README.md ├── include │ ├── wren.h │ └── wren.hpp ├── optional │ ├── wren_opt_meta.c │ ├── wren_opt_meta.h │ ├── wren_opt_meta.wren │ ├── wren_opt_meta.wren.inc │ ├── wren_opt_random.c │ ├── wren_opt_random.h │ ├── wren_opt_random.wren │ └── wren_opt_random.wren.inc └── vm │ ├── wren_common.h │ ├── wren_compiler.c │ ├── wren_compiler.h │ ├── wren_core.c │ ├── wren_core.h │ ├── wren_core.wren │ ├── wren_core.wren.inc │ ├── wren_debug.c │ ├── wren_debug.h │ ├── wren_math.h │ ├── wren_opcodes.h │ ├── wren_primitive.c │ ├── wren_primitive.h │ ├── wren_utils.c │ ├── wren_utils.h │ ├── wren_value.c │ ├── wren_value.h │ ├── wren_vm.c │ └── wren_vm.h ├── test ├── README.md ├── api │ ├── api_tests.c │ ├── api_tests.h │ ├── benchmark.c │ ├── benchmark.h │ ├── call.c │ ├── call.h │ ├── call.wren │ ├── call_calls_foreign.c │ ├── call_calls_foreign.h │ ├── call_calls_foreign.wren │ ├── call_wren_call_root.c │ ├── call_wren_call_root.h │ ├── call_wren_call_root.wren │ ├── error.c │ ├── error.h │ ├── error.wren │ ├── foreign_class.c │ ├── foreign_class.h │ ├── foreign_class.wren │ ├── get_variable.c │ ├── get_variable.h │ ├── get_variable.wren │ ├── get_variable_module.wren │ ├── handle.c │ ├── handle.h │ ├── handle.wren │ ├── lists.c │ ├── lists.h │ ├── lists.wren │ ├── maps.c │ ├── maps.h │ ├── maps.wren │ ├── new_vm.c │ ├── new_vm.h │ ├── new_vm.wren │ ├── reset_stack_after_call_abort.c │ ├── reset_stack_after_call_abort.h │ ├── reset_stack_after_call_abort.wren │ ├── reset_stack_after_foreign_construct.c │ ├── reset_stack_after_foreign_construct.h │ ├── reset_stack_after_foreign_construct.wren │ ├── resolution.c │ ├── resolution.h │ ├── resolution.wren │ ├── slots.c │ ├── slots.h │ ├── slots.wren │ ├── user_data.c │ ├── user_data.h │ └── user_data.wren ├── benchmark │ ├── README.md │ ├── api_call.wren │ ├── api_foreign_method.wren │ ├── binary_trees.dart │ ├── binary_trees.lua │ ├── binary_trees.py │ ├── binary_trees.rb │ ├── binary_trees.wren │ ├── binary_trees_gc.wren │ ├── delta_blue.dart │ ├── delta_blue.lua.inprogress │ ├── delta_blue.py │ ├── delta_blue.wren │ ├── fannkuch.lua │ ├── fannkuch.py │ ├── fannkuch.rb │ ├── fib.dart │ ├── fib.lua │ ├── fib.py │ ├── fib.rb │ ├── fib.wren │ ├── fibers.wren │ ├── for.dart │ ├── for.lua │ ├── for.py │ ├── for.rb │ ├── for.wren │ ├── map_numeric.dart.skip │ ├── map_numeric.lua │ ├── map_numeric.py │ ├── map_numeric.rb │ ├── map_numeric.wren │ ├── map_string.lua │ ├── map_string.py │ ├── map_string.rb │ ├── map_string.wren │ ├── method_call.dart │ ├── method_call.lua │ ├── method_call.py │ ├── method_call.rb │ ├── method_call.wren │ ├── string_equals.py │ └── string_equals.wren ├── core │ ├── bool │ │ ├── equality.wren │ │ ├── no_constructor.wren │ │ ├── not.wren │ │ ├── to_string.wren │ │ └── type.wren │ ├── class │ │ ├── equality.wren │ │ ├── name.wren │ │ ├── no_constructor.wren │ │ ├── supertype.wren │ │ └── type.wren │ ├── fiber │ │ ├── abort.wren │ │ ├── abort_main_fiber.wren │ │ ├── abort_not_string.wren │ │ ├── abort_null.wren │ │ ├── call.wren │ │ ├── call_direct_reenter.wren │ │ ├── call_done.wren │ │ ├── call_error.wren │ │ ├── call_indirect_reenter.wren │ │ ├── call_return_implicit_null.wren │ │ ├── call_return_value.wren │ │ ├── call_root.wren │ │ ├── call_to_parameter.wren │ │ ├── call_transferred.wren │ │ ├── call_with_value.wren │ │ ├── call_with_value_direct_reenter.wren │ │ ├── call_with_value_done.wren │ │ ├── call_with_value_error.wren │ │ ├── call_with_value_indirect_reenter.wren │ │ ├── call_with_value_to_parameter.wren │ │ ├── call_with_value_transferred.wren │ │ ├── error.wren │ │ ├── is_done.wren │ │ ├── is_done_after_error.wren │ │ ├── new_wrong_arg_type.wren │ │ ├── new_wrong_arity.wren │ │ ├── resume_caller.wren │ │ ├── transfer.wren │ │ ├── transfer_direct_reenter.wren │ │ ├── transfer_error.wren │ │ ├── transfer_error_not_string.wren │ │ ├── transfer_indirect_reenter.wren │ │ ├── transfer_return_call_value.wren │ │ ├── transfer_return_transfer_value.wren │ │ ├── transfer_to_done.wren │ │ ├── transfer_to_error.wren │ │ ├── transfer_to_parameter.wren │ │ ├── transfer_to_yielded.wren │ │ ├── transfer_with_value.wren │ │ ├── transfer_with_value_direct_reenter.wren │ │ ├── transfer_with_value_indirect_reenter.wren │ │ ├── transfer_with_value_to_done.wren │ │ ├── transfer_with_value_to_error.wren │ │ ├── transfer_with_value_to_parameter.wren │ │ ├── transfer_with_value_to_yielded.wren │ │ ├── try.wren │ │ ├── try_direct_reenter.wren │ │ ├── try_done.wren │ │ ├── try_error.wren │ │ ├── try_indirect_reenter.wren │ │ ├── try_through_call.wren │ │ ├── try_value.wren │ │ ├── try_value_yield.wren │ │ ├── try_without_error.wren │ │ ├── type.wren │ │ ├── yield.wren │ │ ├── yield_from_import.wren │ │ ├── yield_from_import_module.wren │ │ ├── yield_from_main.wren │ │ ├── yield_return_call_value.wren │ │ ├── yield_return_transfer_value.wren │ │ ├── yield_with_no_caller.wren │ │ ├── yield_with_value.wren │ │ ├── yield_with_value_from_main.wren │ │ └── yield_with_value_with_no_caller.wren │ ├── function │ │ ├── arity.wren │ │ ├── call_extra_arguments.wren │ │ ├── call_missing_arguments.wren │ │ ├── call_runtime_error.wren │ │ ├── equality.wren │ │ ├── new_wrong_arg_type.wren │ │ ├── to_string.wren │ │ └── type.wren │ ├── list │ │ ├── add.wren │ │ ├── add_all.wren │ │ ├── clear.wren │ │ ├── contains.wren │ │ ├── count.wren │ │ ├── count_predicate.wren │ │ ├── count_predicate_non_bool_returning_fn.wren │ │ ├── count_predicate_non_function_arg.wren │ │ ├── each.wren │ │ ├── each_no_items.wren │ │ ├── each_non_function_arg.wren │ │ ├── filled.wren │ │ ├── filled_size_negative.wren │ │ ├── filled_size_not_int.wren │ │ ├── filled_size_not_num.wren │ │ ├── index_of.wren │ │ ├── insert.wren │ │ ├── insert_index_not_int.wren │ │ ├── insert_index_not_num.wren │ │ ├── insert_index_too_large.wren │ │ ├── insert_index_too_small.wren │ │ ├── iterate.wren │ │ ├── iterate_iterator_not_int.wren │ │ ├── iterate_iterator_not_num.wren │ │ ├── iterator_value.wren │ │ ├── iterator_value_iterator_not_int.wren │ │ ├── iterator_value_iterator_not_num.wren │ │ ├── iterator_value_iterator_too_large.wren │ │ ├── iterator_value_iterator_too_small.wren │ │ ├── join.wren │ │ ├── join_separator_not_string.wren │ │ ├── map.wren │ │ ├── multiply.wren │ │ ├── multiply_negative.wren │ │ ├── multiply_not_int.wren │ │ ├── multiply_not_num.wren │ │ ├── new.wren │ │ ├── not.wren │ │ ├── plus.wren │ │ ├── plus_not_iterable.wren │ │ ├── reduce.wren │ │ ├── reduce_no_items.wren │ │ ├── reduce_single_item.wren │ │ ├── reduce_wrong_arity.wren │ │ ├── remove.wren │ │ ├── remove_at.wren │ │ ├── remove_at_index_not_int.wren │ │ ├── remove_at_index_not_num.wren │ │ ├── remove_at_index_too_large.wren │ │ ├── remove_at_index_too_small.wren │ │ ├── sort.wren │ │ ├── subscript.wren │ │ ├── subscript_not_int.wren │ │ ├── subscript_range.wren │ │ ├── subscript_range_from_not_int.wren │ │ ├── subscript_range_from_too_large.wren │ │ ├── subscript_range_from_too_small.wren │ │ ├── subscript_range_to_exclusive_too_large.wren │ │ ├── subscript_range_to_exclusive_too_small.wren │ │ ├── subscript_range_to_not_int.wren │ │ ├── subscript_range_to_too_large.wren │ │ ├── subscript_range_to_too_small.wren │ │ ├── subscript_setter.wren │ │ ├── subscript_setter_not_int.wren │ │ ├── subscript_setter_not_num.wren │ │ ├── subscript_setter_too_large.wren │ │ ├── subscript_setter_too_small.wren │ │ ├── subscript_too_large.wren │ │ ├── subscript_too_small.wren │ │ ├── subscript_wrong_type.wren │ │ ├── swap.wren │ │ ├── to_string.wren │ │ ├── type.wren │ │ └── where.wren │ ├── map │ │ ├── churn.wren │ │ ├── clear.wren │ │ ├── contains_key.wren │ │ ├── contains_key_not_value.wren │ │ ├── count.wren │ │ ├── empty_string_key.wren │ │ ├── is_empty.wren │ │ ├── iterate.wren │ │ ├── iterate_iterator_not_int.wren │ │ ├── iterate_iterator_not_num.wren │ │ ├── iterator_value.wren │ │ ├── iterator_value_iterator_not_int.wren │ │ ├── iterator_value_iterator_not_num.wren │ │ ├── iterator_value_iterator_too_large.wren │ │ ├── iterator_value_iterator_too_small.wren │ │ ├── key_iterate.wren │ │ ├── key_iterate_iterator_not_int.wren │ │ ├── key_iterate_iterator_not_num.wren │ │ ├── key_types.wren │ │ ├── new.wren │ │ ├── remove.wren │ │ ├── remove_key_not_value.wren │ │ ├── reuse_tombstone.wren │ │ ├── subscript_empty_map.wren │ │ ├── subscript_key_not_value.wren │ │ ├── subscript_setter_key_not_value.wren │ │ ├── to_string.wren │ │ ├── type.wren │ │ ├── value_iterate.wren │ │ ├── value_iterate_iterator_not_int.wren │ │ └── value_iterate_iterator_not_num.wren │ ├── map_entry │ │ └── new.wren │ ├── null │ │ ├── no_constructor.wren │ │ ├── not.wren │ │ └── type.wren │ ├── number │ │ ├── abs.wren │ │ ├── acos.wren │ │ ├── asin.wren │ │ ├── atan.wren │ │ ├── atan2.wren │ │ ├── atan2_x_not_num.wren │ │ ├── bitwise_and.wren │ │ ├── bitwise_and_operand_not_num.wren │ │ ├── bitwise_lsh.wren │ │ ├── bitwise_lsh_operand_not_num.wren │ │ ├── bitwise_not.wren │ │ ├── bitwise_or.wren │ │ ├── bitwise_or_operand_not_num.wren │ │ ├── bitwise_rsh.wren │ │ ├── bitwise_rsh_operand_not_num.wren │ │ ├── bitwise_xor.wren │ │ ├── bitwise_xor_operand_not_num.wren │ │ ├── cbrt.wren │ │ ├── ceil.wren │ │ ├── clamp.wren │ │ ├── clamp_max_not_num.wren │ │ ├── clamp_min_not_num.wren │ │ ├── comparison.wren │ │ ├── cos.wren │ │ ├── decimal_point_at_eof.wren │ │ ├── divide.wren │ │ ├── divide_operand_not_num.wren │ │ ├── equality.wren │ │ ├── exp.wren │ │ ├── floor.wren │ │ ├── fraction.wren │ │ ├── from_string.wren │ │ ├── from_string_not_string.wren │ │ ├── from_string_too_large.wren │ │ ├── greater_than_equal_operand_not_num.wren │ │ ├── greater_than_operand_not_num.wren │ │ ├── invalid_hex_literal.wren │ │ ├── is_infinity.wren │ │ ├── is_integer.wren │ │ ├── is_nan.wren │ │ ├── largest.wren │ │ ├── less_than_equal_operand_not_num.wren │ │ ├── less_than_operand_not_num.wren │ │ ├── log.wren │ │ ├── log2.wren │ │ ├── maxSafeInteger.wren │ │ ├── max_other_not_num.wren │ │ ├── minSafeInteger.wren │ │ ├── min_max.wren │ │ ├── min_other_not_num.wren │ │ ├── minus.wren │ │ ├── minus_operand_not_num.wren │ │ ├── mod.wren │ │ ├── mod_operand_not_num.wren │ │ ├── multiply.wren │ │ ├── multiply_operand_not_num.wren │ │ ├── no_constructor.wren │ │ ├── not.wren │ │ ├── plus.wren │ │ ├── plus_operand_not_num.wren │ │ ├── pow.wren │ │ ├── pow_power_not_num.wren │ │ ├── round.wren │ │ ├── sign.wren │ │ ├── sin.wren │ │ ├── smallest.wren │ │ ├── sqrt.wren │ │ ├── tan.wren │ │ ├── to_string.wren │ │ ├── truncate.wren │ │ └── type.wren │ ├── object │ │ ├── is.wren │ │ ├── no_constructor.wren │ │ ├── nonclass_on_right.wren │ │ ├── not.wren │ │ ├── same.wren │ │ ├── to_string.wren │ │ └── type.wren │ ├── range │ │ ├── contains.wren │ │ ├── equality.wren │ │ ├── exclusive_range_wrong_rhs_type.wren │ │ ├── from.wren │ │ ├── inclusive_range_wrong_rhs_type.wren │ │ ├── is_inclusive.wren │ │ ├── iterate.wren │ │ ├── iterate_from_float.wren │ │ ├── iterate_wrong_type.wren │ │ ├── iterator_value.wren │ │ ├── join.wren │ │ ├── join_separator_not_string.wren │ │ ├── map.wren │ │ ├── max.wren │ │ ├── min.wren │ │ ├── no_constructor.wren │ │ ├── reduce.wren │ │ ├── to.wren │ │ ├── to_string.wren │ │ ├── type.wren │ │ └── where.wren │ ├── sequence │ │ ├── all.wren │ │ ├── all_non_function_arg.wren │ │ ├── any.wren │ │ ├── any_non_function_arg.wren │ │ ├── count.wren │ │ ├── is_empty.wren │ │ ├── map.wren │ │ ├── no_constructor.wren │ │ ├── skip.wren │ │ ├── skip_negative.wren │ │ ├── skip_not_int.wren │ │ ├── skip_not_num.wren │ │ ├── take.wren │ │ ├── take_negative.wren │ │ ├── take_not_int.wren │ │ ├── take_not_num.wren │ │ ├── to_list.wren │ │ └── where.wren │ ├── string │ │ ├── bytes.wren │ │ ├── concatenation.wren │ │ ├── concatenation_wrong_arg_type.wren │ │ ├── contains.wren │ │ ├── contains_argument_not_string.wren │ │ ├── count.wren │ │ ├── ends_with.wren │ │ ├── ends_with_invalid_arg.wren │ │ ├── equality.wren │ │ ├── from_byte.wren │ │ ├── from_byte_not_int.wren │ │ ├── from_byte_not_num.wren │ │ ├── from_byte_too_large.wren │ │ ├── from_byte_too_small.wren │ │ ├── from_code_point.wren │ │ ├── from_code_point_not_int.wren │ │ ├── from_code_point_not_num.wren │ │ ├── from_code_point_too_large.wren │ │ ├── from_code_point_too_small.wren │ │ ├── index_of.wren │ │ ├── index_of_invalid_arg.wren │ │ ├── index_of_start.wren │ │ ├── index_of_start_not_int.wren │ │ ├── index_of_start_not_num.wren │ │ ├── index_of_start_too_large.wren │ │ ├── index_of_start_too_small.wren │ │ ├── iterate.wren │ │ ├── iterate_iterator_not_int.wren │ │ ├── iterate_iterator_not_num.wren │ │ ├── iterator_value.wren │ │ ├── iterator_value_iterator_not_int.wren │ │ ├── iterator_value_iterator_not_num.wren │ │ ├── iterator_value_iterator_too_large.wren │ │ ├── iterator_value_iterator_too_small.wren │ │ ├── join.wren │ │ ├── join_separator_not_string.wren │ │ ├── multiply.wren │ │ ├── multiply_negative.wren │ │ ├── multiply_not_int.wren │ │ ├── multiply_not_num.wren │ │ ├── no_constructor.wren │ │ ├── not.wren │ │ ├── replace.wren │ │ ├── replace_empty_old.wren │ │ ├── replace_new_not_string.wren │ │ ├── replace_old_not_string.wren │ │ ├── split.wren │ │ ├── split_argument_not_string.wren │ │ ├── split_empty_seperator.wren │ │ ├── starts_with.wren │ │ ├── starts_with_invalid_arg.wren │ │ ├── subscript.wren │ │ ├── subscript_not_int.wren │ │ ├── subscript_not_num.wren │ │ ├── subscript_range.wren │ │ ├── subscript_range_from_not_int.wren │ │ ├── subscript_range_from_too_large.wren │ │ ├── subscript_range_from_too_small.wren │ │ ├── subscript_range_to_exclusive_too_large.wren │ │ ├── subscript_range_to_exclusive_too_small.wren │ │ ├── subscript_range_to_not_int.wren │ │ ├── subscript_range_to_too_large.wren │ │ ├── subscript_range_to_too_small.wren │ │ ├── subscript_too_large.wren │ │ ├── subscript_too_small.wren │ │ ├── to_string.wren │ │ ├── trim.wren │ │ ├── trim_chars_not_string.wren │ │ ├── trim_end.wren │ │ ├── trim_end_chars_not_string.wren │ │ ├── trim_start.wren │ │ ├── trim_start_chars_not_string.wren │ │ └── type.wren │ ├── string_byte_sequence │ │ ├── count.wren │ │ ├── iterate.wren │ │ ├── iterate_not_int.wren │ │ ├── iterate_wrong_type.wren │ │ ├── iterator_value.wren │ │ ├── iterator_value_not_int.wren │ │ ├── iterator_value_not_num.wren │ │ ├── iterator_value_too_large.wren │ │ ├── iterator_value_too_small.wren │ │ ├── subscript.wren │ │ ├── subscript_not_int.wren │ │ ├── subscript_not_num.wren │ │ ├── subscript_too_large.wren │ │ └── subscript_too_small.wren │ ├── string_code_point_sequence │ │ ├── count.wren │ │ ├── iterate.wren │ │ ├── iterate_iterator_not_int.wren │ │ ├── iterate_iterator_not_num.wren │ │ ├── iterator_value.wren │ │ ├── iterator_value_incomplete.wren │ │ ├── iterator_value_not_int.wren │ │ ├── iterator_value_not_num.wren │ │ ├── iterator_value_too_large.wren │ │ ├── iterator_value_too_small.wren │ │ ├── subscript.wren │ │ ├── subscript_incomplete.wren │ │ ├── subscript_not_int.wren │ │ ├── subscript_not_num.wren │ │ ├── subscript_too_large.wren │ │ └── subscript_too_small.wren │ └── system │ │ ├── print.wren │ │ ├── print_all.wren │ │ ├── print_all_not_sequence.wren │ │ ├── print_bad_to_string.wren │ │ ├── write_all.wren │ │ ├── write_all_not_sequence.wren │ │ └── write_bad_to_string.wren ├── language │ ├── assignment │ │ ├── associativity.wren │ │ ├── global.wren │ │ ├── grouping.wren │ │ ├── infix_operator.wren │ │ ├── is.wren │ │ ├── local.wren │ │ ├── prefix_operator.wren │ │ ├── syntax.wren │ │ └── undefined.wren │ ├── bitwise_precedence.wren │ ├── bom.wren │ ├── break │ │ ├── closure_in_for.wren │ │ ├── closure_in_while.wren │ │ ├── exit_local_scopes.wren │ │ ├── in_for_loop.wren │ │ ├── in_function_in_loop.wren │ │ ├── in_method_in_loop.wren │ │ ├── in_while_loop.wren │ │ ├── nested_for_loop.wren │ │ ├── nested_while_loop.wren │ │ └── outside_loop.wren │ ├── chained_newline.wren │ ├── class │ │ ├── attributes │ │ │ ├── attributes.wren │ │ │ ├── compile_only.wren │ │ │ ├── duplicate_keys.wren │ │ │ ├── groups.wren │ │ │ ├── invalid_expression.wren │ │ │ ├── invalid_scope.wren │ │ │ ├── invalid_toplevel.wren │ │ │ ├── literals.wren │ │ │ ├── methods.wren │ │ │ └── without.wren │ │ ├── field_in_foreign_class.wren │ │ ├── foreign_class_inherit_fields.wren │ │ ├── lowercase_name_inside_body.wren │ │ ├── missing_class_after_foreign.wren │ │ ├── name_inside_body.wren │ │ ├── newline_after_class.wren │ │ ├── newline_after_static.wren │ │ └── syntax.wren │ ├── closure │ │ ├── assign_to_closure.wren │ │ ├── close_over_function_parameter.wren │ │ ├── close_over_later_variable.wren │ │ ├── close_over_method_parameter.wren │ │ ├── closed_closure_in_function.wren │ │ ├── nested_closure.wren │ │ ├── open_closure_in_function.wren │ │ ├── reference_closure_multiple_times.wren │ │ ├── reuse_closure_slot.wren │ │ ├── shadow_closure_with_local.wren │ │ ├── unused_closure.wren │ │ └── unused_later_closure.wren │ ├── comments │ │ ├── block.wren │ │ ├── block_at_eof.wren │ │ ├── line_at_eof.wren │ │ ├── only_line_comment.wren │ │ ├── only_line_comment_and_line.wren │ │ ├── unicode.wren │ │ ├── unterminated_block.wren │ │ └── unterminated_nested_block.wren │ ├── conditional │ │ ├── conditional_in_then.wren │ │ ├── missing_colon.wren │ │ ├── missing_condition.wren │ │ ├── missing_else.wren │ │ ├── missing_question.wren │ │ ├── missing_then.wren │ │ ├── newlines.wren │ │ ├── precedence.wren │ │ └── short_circuit.wren │ ├── constructor │ ├── continue │ │ ├── closure_in_for.wren │ │ ├── closure_in_while.wren │ │ ├── exit_local_scopes.wren │ │ ├── in_for_loop.wren │ │ ├── in_function_in_loop.wren │ │ ├── in_method_in_loop.wren │ │ ├── in_while_loop.wren │ │ ├── nested_for_loop.wren │ │ ├── nested_while_loop.wren │ │ └── outside_loop.wren │ ├── deeply_nested_gc.wren │ ├── empty_block.wren │ ├── empty_file.wren │ ├── fiber │ │ └── closure.wren │ ├── field │ │ ├── closure.wren │ │ ├── default_to_null.wren │ │ ├── in_fn_in_static_method.wren │ │ ├── in_static_method.wren │ │ ├── in_static_method_in_nested_class.wren │ │ ├── multiple.wren │ │ ├── nested_class.wren │ │ ├── object_reference.wren │ │ ├── outside_class.wren │ │ └── use_before_set.wren │ ├── for │ │ ├── close_over_loop_variable.wren │ │ ├── closure_in_body.wren │ │ ├── newline_after_for.wren │ │ ├── newline_before_in.wren │ │ ├── only_evaluate_sequence_once.wren │ │ ├── return_closure.wren │ │ ├── return_inside.wren │ │ ├── syntax.wren │ │ └── truth.wren │ ├── foreign │ │ ├── foreign_after_static.wren │ │ ├── foreign_method_with_body.wren │ │ └── unknown_method.wren │ ├── function │ │ ├── empty_body.wren │ │ ├── newline_body.wren │ │ ├── newline_in_expression_block.wren │ │ ├── no_newline_before_close.wren │ │ ├── no_parameters.wren │ │ ├── parameters.wren │ │ └── syntax.wren │ ├── if │ │ ├── dangling_else.wren │ │ ├── else.wren │ │ ├── if.wren │ │ ├── newline_after_else.wren │ │ ├── newline_after_if.wren │ │ └── truth.wren │ ├── ignore_carriage_returns.wren │ ├── implicit_receiver │ │ ├── inherited_methods.wren │ │ ├── instance_methods.wren │ │ ├── locals_shadow_getter.wren │ │ ├── locals_shadow_setter.wren │ │ ├── nested_class.wren │ │ └── static_methods.wren │ ├── inheritance │ │ ├── do_not_inherit_static_methods.wren │ │ ├── inherit_fields.wren │ │ ├── inherit_from_bool.wren │ │ ├── inherit_from_class.wren │ │ ├── inherit_from_closure.wren │ │ ├── inherit_from_fiber.wren │ │ ├── inherit_from_fn.wren │ │ ├── inherit_from_list.wren │ │ ├── inherit_from_map.wren │ │ ├── inherit_from_nonclass.wren │ │ ├── inherit_from_null.wren │ │ ├── inherit_from_null_class.wren │ │ ├── inherit_from_num.wren │ │ ├── inherit_from_range.wren │ │ ├── inherit_from_string.wren │ │ ├── inherit_methods.wren │ │ ├── inherited_fields_in_closure.wren │ │ └── is.wren │ ├── interpolation │ │ ├── empty.wren │ │ ├── interpolation.wren │ │ ├── runtime_error_in_expression.wren │ │ ├── switch_fiber.wren │ │ ├── unterminated.wren │ │ └── unterminated_expression.wren │ ├── list │ │ ├── duplicate_comma.wren │ │ ├── duplicate_trailing_comma.wren │ │ ├── empty_list_with_comma.wren │ │ ├── eof_after_comma.wren │ │ ├── eof_after_element.wren │ │ ├── grow_shrink.wren │ │ ├── newline_before_comma.wren │ │ ├── newlines.wren │ │ └── trailing_comma.wren │ ├── logical_operator │ │ ├── and.wren │ │ ├── and_truth.wren │ │ ├── or.wren │ │ └── or_truth.wren │ ├── many_reallocations.wren │ ├── map │ │ ├── bad_key_precedence.wren │ │ ├── duplicate_comma.wren │ │ ├── duplicate_trailing_comma.wren │ │ ├── empty_map_with_comma.wren │ │ ├── eof_after_colon.wren │ │ ├── eof_after_comma.wren │ │ ├── eof_after_key.wren │ │ ├── eof_after_value.wren │ │ ├── grow_and_shrink.wren │ │ ├── newlines.wren │ │ ├── precedence.wren │ │ └── trailing_comma.wren │ ├── method │ │ ├── arity.wren │ │ ├── call_name_too_long.wren │ │ ├── duplicate_methods.wren │ │ ├── empty_block.wren │ │ ├── empty_subscript_call.wren │ │ ├── empty_subscript_definition.wren │ │ ├── long_name.wren │ │ ├── many_methods.wren │ │ ├── name_too_long.wren │ │ ├── newlines.wren │ │ ├── no_parameters_new_line.wren │ │ ├── not_found.wren │ │ ├── not_found_eleven_arguments.wren │ │ ├── not_found_multiple_arguments.wren │ │ ├── not_found_one_argument.wren │ │ ├── operators.wren │ │ ├── static.wren │ │ ├── static_method_not_found.wren │ │ ├── static_operators.wren │ │ ├── subscript_operators.wren │ │ ├── subscript_setter_too_many_arguments.wren │ │ ├── subscript_too_many_arguments.wren │ │ ├── too_many_arguments.wren │ │ └── too_many_parameters.wren │ ├── module │ │ ├── change_imported_value │ │ │ ├── change_imported_value.wren │ │ │ └── module.wren │ │ ├── compile_error │ │ │ ├── compile_error.wren │ │ │ └── module.wren │ │ ├── cyclic_import │ │ │ ├── a.wren │ │ │ ├── b.wren │ │ │ └── cyclic_import.wren │ │ ├── implicitly_imports_core │ │ │ ├── implicitly_imports_core.wren │ │ │ └── module.wren │ │ ├── import_as │ │ │ ├── import_as.wren │ │ │ └── module.wren │ │ ├── inside_block │ │ │ ├── inside_block.wren │ │ │ └── module.wren │ │ ├── missing_for.wren │ │ ├── missing_string_after_import.wren │ │ ├── module_dir │ │ │ ├── module_dir.wren │ │ │ └── something │ │ │ │ └── module.wren │ │ ├── multiple_variables │ │ │ ├── module.wren │ │ │ └── multiple_variables.wren │ │ ├── name_collision.wren │ │ ├── newlines │ │ │ ├── module.wren │ │ │ └── newlines.wren │ │ ├── no_variable │ │ │ ├── module.wren │ │ │ └── no_variable.wren │ │ ├── relative_import │ │ │ ├── module_3.wren │ │ │ ├── relative_import.wren │ │ │ └── sub │ │ │ │ ├── dir │ │ │ │ ├── module.wren │ │ │ │ └── module_2.wren │ │ │ │ ├── module.wren │ │ │ │ ├── module_2.wren │ │ │ │ └── module_3.wren │ │ ├── returns │ │ │ ├── module_return.wren │ │ │ ├── module_return_value.wren │ │ │ ├── return.wren │ │ │ ├── return_from_import.wren │ │ │ ├── return_value.wren │ │ │ └── return_value_from_import.wren │ │ ├── shared_import │ │ │ ├── a.wren │ │ │ ├── b.wren │ │ │ ├── shared.wren │ │ │ └── shared_import.wren │ │ ├── simple_import │ │ │ ├── module.wren │ │ │ └── simple_import.wren │ │ ├── unknown_module.wren │ │ └── unknown_variable │ │ │ ├── module.wren │ │ │ └── unknown_variable.wren │ ├── no_trailing_newline.wren │ ├── nonlocal │ │ ├── assignment.wren │ │ ├── duplicate_nonlocal.wren │ │ ├── in_block_scope.wren │ │ ├── localname_forward_declare.wren │ │ ├── mutual_recursion.wren │ │ ├── nonlocal_in_initializer.wren │ │ ├── nonlocal_without_initializer.wren │ │ ├── null_before_defined.wren │ │ ├── undefined.wren │ │ ├── use_in_function.wren │ │ ├── use_in_function_before_definition.wren │ │ ├── use_in_method.wren │ │ └── use_in_method_before_definition.wren │ ├── null │ │ └── literal.wren │ ├── number │ │ ├── hex_literals.wren │ │ ├── hex_too_large.wren │ │ ├── literal_too_large.wren │ │ ├── literals.wren │ │ ├── scientific_float_missing_exponent.wren │ │ ├── scientific_floating_exponent.wren │ │ ├── scientific_literals.wren │ │ ├── scientific_missing_exponent.wren │ │ ├── scientific_missing_fractional_part.wren │ │ ├── scientific_multiple_exponants.wren │ │ └── scientific_multiple_exponent_signs.wren │ ├── precedence.wren │ ├── return │ │ ├── after_else.wren │ │ ├── after_if.wren │ │ ├── after_while.wren │ │ ├── in_function.wren │ │ ├── in_method.wren │ │ └── return_null_if_newline.wren │ ├── semicolon.wren │ ├── setter │ │ ├── associativity.wren │ │ ├── grouping.wren │ │ ├── infix_operator.wren │ │ ├── instance.wren │ │ ├── is.wren │ │ ├── prefix_operator.wren │ │ ├── result.wren │ │ ├── same_name_as_method.wren │ │ └── static.wren │ ├── shebang │ │ ├── shebang.wren │ │ ├── shebang_at_eof.wren │ │ ├── shebang_at_other_line.wren │ │ └── shebang_invalid.wren │ ├── static_field │ │ ├── closure.wren │ │ ├── default_to_null.wren │ │ ├── in_instance_method.wren │ │ ├── multiple.wren │ │ ├── nested_class.wren │ │ ├── outside_class.wren │ │ └── use_before_set.wren │ ├── string │ │ ├── byte_escapes.wren │ │ ├── escapes.wren │ │ ├── incomplete_byte_escape.wren │ │ ├── incomplete_byte_escape_at_eof.wren │ │ ├── incomplete_long_unicode_escape.wren │ │ ├── incomplete_unicode_escape.wren │ │ ├── incomplete_unicode_escape_at_eof.wren │ │ ├── invalid_byte_escape.wren │ │ ├── invalid_escape.wren │ │ ├── invalid_unicode_escape.wren │ │ ├── literals.wren │ │ ├── unicode_escapes.wren │ │ ├── unicode_two_bytes_to_long_escape.wren │ │ ├── unterminated.wren │ │ └── unterminated_raw.wren │ ├── super │ │ ├── call_different_arity.wren │ │ ├── call_other_method.wren │ │ ├── call_same_method.wren │ │ ├── closure.wren │ │ ├── implicit_name.wren │ │ ├── indirectly_inherited.wren │ │ ├── no_superclass_method.wren │ │ ├── super_at_top_level.wren │ │ ├── super_in_closure_in_inherited_method.wren │ │ ├── super_in_inherited_method.wren │ │ ├── super_in_static_method.wren │ │ └── super_in_top_level_function.wren │ ├── this │ │ ├── closure.wren │ │ ├── nested_class.wren │ │ ├── nested_closure.wren │ │ ├── this_at_top_level.wren │ │ ├── this_in_method.wren │ │ ├── this_in_static_method.wren │ │ └── this_in_top_level_function.wren │ ├── unexpected_character.wren │ ├── variable │ │ ├── duplicate_local.wren │ │ ├── duplicate_parameter.wren │ │ ├── global_in_initializer.wren │ │ ├── global_without_initializer.wren │ │ ├── local_collide_with_function_parameter.wren │ │ ├── local_collide_with_method_parameter.wren │ │ ├── local_in_initializer.wren │ │ ├── local_in_middle_of_block.wren │ │ ├── local_in_nested_block.wren │ │ ├── local_outside_method.wren │ │ ├── local_without_initializer.wren │ │ ├── many_locals.wren │ │ ├── many_nonsimultaneous_locals.wren │ │ ├── newline_after_equals.wren │ │ ├── newline_after_var.wren │ │ ├── outside_method.wren │ │ ├── scope_if.wren │ │ ├── scope_reuse_in_different_blocks.wren │ │ ├── scope_while.wren │ │ ├── shadow_and_local.wren │ │ ├── shadow_global.wren │ │ ├── shadow_in_initializer.wren │ │ ├── shadow_local.wren │ │ ├── too_many_locals.wren │ │ ├── too_many_locals_nested.wren │ │ ├── undefined_global.wren │ │ ├── undefined_local.wren │ │ ├── use_false_as_var.wren │ │ ├── use_field_as_var.wren │ │ ├── use_null_as_var.wren │ │ ├── use_this_as_var.wren │ │ └── use_true_as_var.wren │ ├── while │ │ ├── closure_in_body.wren │ │ ├── newline_after_while.wren │ │ ├── return_closure.wren │ │ ├── return_inside.wren │ │ ├── syntax.wren │ │ └── truth.wren │ └── whitespace.wren ├── limit │ ├── interpolation_nesting.wren │ ├── jump_too_far.wren │ ├── long_function.wren │ ├── long_string.wren │ ├── long_variable_name.wren │ ├── loop_too_far.wren │ ├── many_constants.wren │ ├── many_fields.wren │ ├── many_globals.wren │ ├── many_inherited_fields.wren │ ├── reuse_constants.wren │ ├── too_many_constants.wren │ ├── too_many_fields.wren │ ├── too_many_function_parameters.wren │ ├── too_many_inherited_fields.wren │ ├── too_much_interpolation_nesting.wren │ └── variable_name_too_long.wren ├── main.c ├── meta │ ├── eval_compile_error.wren │ ├── eval_existing_scoped_variable.wren │ ├── eval_not_string.wren │ ├── get_module_variables.wren │ ├── get_module_variables_not_string.wren │ └── get_module_variables_unknown_module.wren ├── random │ ├── float.wren │ ├── float_max.wren │ ├── float_min_max.wren │ ├── int.wren │ ├── int_max.wren │ ├── int_min_max.wren │ ├── new.wren │ ├── new_empty_sequence.wren │ ├── new_number.wren │ ├── new_sequence.wren │ ├── new_wrong_arg_type.wren │ ├── new_wrong_element_type.wren │ ├── sample_count_multiple.wren │ ├── sample_count_one.wren │ ├── sample_count_too_many.wren │ ├── sample_count_zero.wren │ ├── sample_one.wren │ ├── sample_one_empty.wren │ └── shuffle.wren ├── regression │ ├── 428.wren │ ├── 429.wren │ ├── 442-000005.wren │ ├── 442-000007.wren │ ├── 442-000086.wren │ ├── 442-000088.wren │ ├── 442-000089.wren │ ├── 442-000100.wren │ ├── 442-000115.wren │ ├── 442-000166.wren │ ├── 442-000181.wren │ ├── 442-000182.wren │ ├── 442-000238.wren │ ├── 442-000295.wren │ ├── 442-000321.wren │ ├── 442-000348.wren │ ├── 442-000357.wren │ ├── 442-000440.wren │ ├── 442-000665.wren │ ├── 494.wren │ └── 561.wren ├── test.c ├── test.h └── unit │ ├── main.c │ ├── path_test.c │ ├── path_test.h │ ├── test.c │ └── test.h ├── try ├── main.try.c ├── make.emscripten │ ├── Makefile │ ├── wren.make │ └── wren_try.make └── readme.md └── util ├── benchmark.py ├── deploy_docs_from_travis.sh ├── generate_amalgamation.py ├── generate_docs.py ├── generate_projects.py ├── metrics.py ├── test.py └── wren_to_c_string.py /doc/site/cli/modules/io/index.markdown: -------------------------------------------------------------------------------- 1 | ^title Module "io" 2 | 3 | Provides access to operating system streams and the file system. 4 | 5 | * [Directory](directory.html) 6 | * [File](file.html) 7 | * [Stat](stat.html) 8 | * [Stdin](stdin.html) 9 | * [Stdout](stdout.html) 10 | -------------------------------------------------------------------------------- /doc/site/cli/modules/io/stdout.markdown: -------------------------------------------------------------------------------- 1 | ^title Stdout Class 2 | 3 | The standard output stream. 4 | 5 | ## Static Methods 6 | 7 | ### **flush()** 8 | 9 | Flushes all buffered data to the stream. Ensures any data written to stdout 10 | that is in the buffer gets written to the file or terminal that stdout is 11 | connected to. 12 | -------------------------------------------------------------------------------- /doc/site/cli/modules/os/index.markdown: -------------------------------------------------------------------------------- 1 | ^title Module "os" 2 | 3 | The os module exposes classes for accessing capabilities provided by the 4 | underlying operating system. 5 | 6 | * [Platform](platform.html) 7 | * [Process](process.html) 8 | -------------------------------------------------------------------------------- /doc/site/cli/modules/scheduler/index.markdown: -------------------------------------------------------------------------------- 1 | ^title Module "scheduler" 2 | 3 | This module provides a vehicle to allow other operations to be performed asynchronously whilst waiting for the main operation to be completed. 4 | 5 | It contains a single class: 6 | 7 | * [Scheduler](scheduler.html) 8 | -------------------------------------------------------------------------------- /doc/site/cli/modules/timer/index.markdown: -------------------------------------------------------------------------------- 1 | ^title Module "timer" 2 | 3 | This module provides a mechanism to suspend the current fiber for a given period of time either as a simple delay or to allow other operations to be performed asynchronously in the meantime. 4 | 5 | It contains a single class: 6 | 7 | * [Timer](timer.html) 8 | -------------------------------------------------------------------------------- /doc/site/modules/core/index.markdown: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /doc/site/modules/core/null.markdown: -------------------------------------------------------------------------------- 1 | ^title Null Class 2 | 3 | ## Methods 4 | 5 | ### **!** operator 6 | 7 | Returns `true`, since `null` is considered [false](../../control-flow.html#truth). 8 | 9 |
10 | System.print(!null) //> true
11 | 
12 | -------------------------------------------------------------------------------- /doc/site/modules/meta/index.markdown: -------------------------------------------------------------------------------- 1 | ^title Module "meta" 2 | 3 | This module enables Wren to do certain kinds of meta-programming. 4 | 5 | It is an optional module. You can omit it from your application by setting the preprocessor constant `WREN_OPT_META` to `0`. 6 | 7 | It contains a single class: 8 | 9 | * [Meta](meta.html) 10 | -------------------------------------------------------------------------------- /doc/site/modules/random/index.markdown: -------------------------------------------------------------------------------- 1 | ^title Module "random" 2 | 3 | This module provides a simple, fast pseudo-random number generator. 4 | 5 | It is an optional module. You can omit it from your application by setting the 6 | preprocessor constant `WREN_OPT_RANDOM` to `0`. 7 | 8 | It contains a single class: 9 | 10 | * [Random](random.html) 11 | -------------------------------------------------------------------------------- /doc/site/static/wren_try.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/doc/site/static/wren_try.wasm -------------------------------------------------------------------------------- /example/hello.wren: -------------------------------------------------------------------------------- 1 | System.print("Hello, world!") 2 | -------------------------------------------------------------------------------- /example/import_module/cthulu.wren: -------------------------------------------------------------------------------- 1 | class Cthulu { 2 | construct new() {} 3 | message { "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn" } 4 | } 5 | -------------------------------------------------------------------------------- /example/import_module/lovecraft.wren: -------------------------------------------------------------------------------- 1 | import "./cthulu" for Cthulu 2 | 3 | class Lovecraft { 4 | construct new() {} 5 | say() { Cthulu.new().message } 6 | } 7 | 8 | System.print(Lovecraft.new().say()) 9 | -------------------------------------------------------------------------------- /projects/premake/premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/projects/premake/premake5.exe -------------------------------------------------------------------------------- /projects/xcode/wren.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /src/include/wren.hpp: -------------------------------------------------------------------------------- 1 | #ifndef wren_hpp 2 | #define wren_hpp 3 | 4 | // This is a convenience header for users that want to compile Wren as C and 5 | // link to it from a C++ application. 6 | 7 | extern "C" { 8 | #include "wren.h" 9 | } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /test/api/benchmark.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn benchmarkBindMethod(const char* signature); 4 | -------------------------------------------------------------------------------- /test/api/call.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | int callRunTests(WrenVM* vm); 4 | -------------------------------------------------------------------------------- /test/api/call_calls_foreign.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn callCallsForeignBindMethod(const char* signature); 4 | int callCallsForeignRunTests(WrenVM* vm); 5 | -------------------------------------------------------------------------------- /test/api/call_wren_call_root.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | int callWrenCallRootRunTests(WrenVM* vm); 4 | -------------------------------------------------------------------------------- /test/api/error.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn errorBindMethod(const char* signature); 4 | -------------------------------------------------------------------------------- /test/api/error.wren: -------------------------------------------------------------------------------- 1 | class Error { 2 | foreign static runtimeError 3 | } 4 | 5 | var fiber = Fiber.new { 6 | Error.runtimeError 7 | } 8 | 9 | var error = fiber.try() 10 | System.print(error) // expect: Error! 11 | System.print(fiber.isDone) // expect: true 12 | System.print(fiber.error) // expect: Error! 13 | -------------------------------------------------------------------------------- /test/api/foreign_class.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn foreignClassBindMethod(const char* signature); 4 | void foreignClassBindClass( 5 | const char* className, WrenForeignClassMethods* methods); 6 | -------------------------------------------------------------------------------- /test/api/get_variable.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn getVariableBindMethod(const char* signature); 4 | -------------------------------------------------------------------------------- /test/api/get_variable_module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | 3 | var Variable = "value" 4 | -------------------------------------------------------------------------------- /test/api/handle.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn handleBindMethod(const char* signature); 4 | -------------------------------------------------------------------------------- /test/api/handle.wren: -------------------------------------------------------------------------------- 1 | class Handle { 2 | foreign static value=(value) 3 | foreign static value 4 | } 5 | 6 | Handle.value = ["list", "of", "strings"] 7 | 8 | // Make sure the handle lives through a GC. 9 | System.gc() 10 | 11 | System.print(Handle.value) // expect: [list, of, strings] 12 | -------------------------------------------------------------------------------- /test/api/lists.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn listsBindMethod(const char* signature); 4 | -------------------------------------------------------------------------------- /test/api/maps.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn mapsBindMethod(const char* signature); 4 | void mapBindClass( 5 | const char* className, WrenForeignClassMethods* methods); 6 | -------------------------------------------------------------------------------- /test/api/new_vm.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn newVMBindMethod(const char* signature); 4 | -------------------------------------------------------------------------------- /test/api/new_vm.wren: -------------------------------------------------------------------------------- 1 | class VM { 2 | foreign static nullConfig() 3 | foreign static multipleInterpretCalls() 4 | } 5 | // TODO: Other configuration settings. 6 | 7 | System.print(VM.nullConfig()) // expect: true 8 | System.print(VM.multipleInterpretCalls()) // expect: true 9 | -------------------------------------------------------------------------------- /test/api/reset_stack_after_call_abort.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | int resetStackAfterCallAbortRunTests(WrenVM* vm); -------------------------------------------------------------------------------- /test/api/reset_stack_after_foreign_construct.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | void resetStackAfterForeignConstructBindClass( 4 | const char* className, WrenForeignClassMethods* methods); 5 | int resetStackAfterForeignConstructRunTests(WrenVM* vm); -------------------------------------------------------------------------------- /test/api/resolution.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn resolutionBindMethod(const char* signature); 4 | void resolutionBindClass(const char* className, WrenForeignClassMethods* methods); 5 | -------------------------------------------------------------------------------- /test/api/slots.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn slotsBindMethod(const char* signature); 4 | void slotsBindClass(const char* className, WrenForeignClassMethods* methods); 5 | -------------------------------------------------------------------------------- /test/api/user_data.h: -------------------------------------------------------------------------------- 1 | #include "wren.h" 2 | 3 | WrenForeignMethodFn userDataBindMethod(const char* signature); 4 | -------------------------------------------------------------------------------- /test/api/user_data.wren: -------------------------------------------------------------------------------- 1 | class UserData { 2 | foreign static test 3 | } 4 | 5 | System.print(UserData.test) // expect: true 6 | -------------------------------------------------------------------------------- /test/benchmark/api_call.wren: -------------------------------------------------------------------------------- 1 | class Benchmark { 2 | foreign static call(iterations) 3 | } 4 | 5 | var result = Benchmark.call(1000000) 6 | // Returns false if it didn't calculate the right value. Otherwise returns the 7 | // elapsed time. 8 | System.print(result is Num) 9 | System.print("elapsed: %(result)") 10 | -------------------------------------------------------------------------------- /test/benchmark/fib.dart: -------------------------------------------------------------------------------- 1 | fib(n) { 2 | if (n < 2) return n; 3 | return fib(n - 1) + fib(n - 2); 4 | } 5 | 6 | main() { 7 | Stopwatch watch = new Stopwatch(); 8 | watch.start(); 9 | for (var i = 0; i < 5; i++) { 10 | print(fib(28)); 11 | } 12 | print("elapsed: ${watch.elapsedMilliseconds / 1000}"); 13 | } 14 | -------------------------------------------------------------------------------- /test/benchmark/fib.lua: -------------------------------------------------------------------------------- 1 | function fib(n) 2 | if n < 2 then return n end 3 | return fib(n - 2) + fib(n - 1) 4 | end 5 | 6 | local start = os.clock() 7 | for i = 1, 5 do 8 | io.write(fib(28) .. "\n") 9 | end 10 | io.write(string.format("elapsed: %.8f\n", os.clock() - start)) 11 | -------------------------------------------------------------------------------- /test/benchmark/fib.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | import time 4 | 5 | def fib(n): 6 | if n < 2: return n 7 | return fib(n - 1) + fib(n - 2) 8 | 9 | start = time.process_time() 10 | for i in range(0, 5): 11 | print(fib(28)) 12 | print("elapsed: " + str(time.process_time() - start)) -------------------------------------------------------------------------------- /test/benchmark/fib.rb: -------------------------------------------------------------------------------- 1 | def fib(n) 2 | if n < 2 then 3 | n 4 | else 5 | fib(n - 1) + fib(n - 2) 6 | end 7 | end 8 | 9 | start = Time.now 10 | for i in 0...5 11 | puts fib(28) 12 | end 13 | puts "elapsed: " + (Time.now - start).to_s 14 | -------------------------------------------------------------------------------- /test/benchmark/fib.wren: -------------------------------------------------------------------------------- 1 | class Fib { 2 | static get(n) { 3 | if (n < 2) return n 4 | return get(n - 1) + get(n - 2) 5 | } 6 | } 7 | 8 | var start = System.clock 9 | for (i in 1..5) { 10 | System.print(Fib.get(28)) 11 | } 12 | System.print("elapsed: %(System.clock - start)") 13 | -------------------------------------------------------------------------------- /test/benchmark/for.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | var list = []; 3 | 4 | Stopwatch watch = new Stopwatch(); 5 | watch.start(); 6 | for (var i = 0; i < 1000000; i++) list.add(i); 7 | 8 | var sum = 0; 9 | for (i in list) sum += i; 10 | 11 | print(sum); 12 | print("elapsed: ${watch.elapsedMilliseconds / 1000}"); 13 | } 14 | -------------------------------------------------------------------------------- /test/benchmark/for.lua: -------------------------------------------------------------------------------- 1 | local start = os.clock() 2 | local list = {} 3 | for i = 0, 999999 do 4 | list[i] = i 5 | end 6 | 7 | local sum = 0 8 | for k, i in pairs(list) do 9 | sum = sum + i 10 | end 11 | io.write(sum .. "\n") 12 | io.write(string.format("elapsed: %.8f\n", os.clock() - start)) 13 | -------------------------------------------------------------------------------- /test/benchmark/for.rb: -------------------------------------------------------------------------------- 1 | start = Time.now 2 | list = [] 3 | 1000000.times {|i| list << i} 4 | 5 | sum = 0 6 | list.each {|i| sum += i} 7 | puts sum 8 | puts "elapsed: " + (Time.now - start).to_s 9 | -------------------------------------------------------------------------------- /test/benchmark/for.wren: -------------------------------------------------------------------------------- 1 | var list = [] 2 | 3 | var start = System.clock 4 | for (i in 0...1000000) list.add(i) 5 | 6 | var sum = 0 7 | for (i in list) sum = sum + i 8 | 9 | System.print(sum) 10 | System.print("elapsed: %(System.clock - start)") 11 | -------------------------------------------------------------------------------- /test/benchmark/map_numeric.rb: -------------------------------------------------------------------------------- 1 | start = Time.now 2 | 3 | map = Hash.new 4 | 5 | for i in (1..2000000) 6 | map[i] = i 7 | end 8 | 9 | sum = 0 10 | for i in (1..2000000) 11 | sum = sum + map[i] 12 | end 13 | puts sum 14 | 15 | for i in (1..2000000) 16 | map.delete(i) 17 | end 18 | 19 | puts "elapsed: " + (Time.now - start).to_s 20 | -------------------------------------------------------------------------------- /test/benchmark/map_numeric.wren: -------------------------------------------------------------------------------- 1 | var start = System.clock 2 | 3 | var map = {} 4 | 5 | for (i in 1..2000000) { 6 | map[i] = i 7 | } 8 | 9 | var sum = 0 10 | for (i in 1..2000000) { 11 | sum = sum + map[i] 12 | } 13 | System.print(sum) 14 | 15 | for (i in 1..2000000) { 16 | map.remove(i) 17 | } 18 | 19 | System.print("elapsed: %(System.clock - start)") 20 | -------------------------------------------------------------------------------- /test/core/bool/no_constructor.wren: -------------------------------------------------------------------------------- 1 | Bool.new() // expect runtime error: Bool metaclass does not implement 'new()'. 2 | -------------------------------------------------------------------------------- /test/core/bool/not.wren: -------------------------------------------------------------------------------- 1 | System.print(!true) // expect: false 2 | System.print(!false) // expect: true 3 | System.print(!!true) // expect: true 4 | -------------------------------------------------------------------------------- /test/core/bool/to_string.wren: -------------------------------------------------------------------------------- 1 | System.print(true.toString) // expect: true 2 | System.print(false.toString) // expect: false 3 | -------------------------------------------------------------------------------- /test/core/bool/type.wren: -------------------------------------------------------------------------------- 1 | System.print(true is Bool) // expect: true 2 | System.print(true is Object) // expect: true 3 | System.print(true is Num) // expect: false 4 | System.print(true.type == Bool) // expect: true 5 | -------------------------------------------------------------------------------- /test/core/class/no_constructor.wren: -------------------------------------------------------------------------------- 1 | Class.new() // expect runtime error: Class does not implement 'new()'. 2 | -------------------------------------------------------------------------------- /test/core/fiber/abort.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | Fiber.abort("Error message.") 3 | } 4 | 5 | System.print(fiber.try()) // expect: Error message. 6 | System.print(fiber.isDone) // expect: true 7 | System.print(fiber.error) // expect: Error message. 8 | -------------------------------------------------------------------------------- /test/core/fiber/abort_main_fiber.wren: -------------------------------------------------------------------------------- 1 | Fiber.abort("Abort!") // expect runtime error: Abort! 2 | -------------------------------------------------------------------------------- /test/core/fiber/abort_not_string.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | Fiber.abort(123) 3 | } 4 | 5 | System.print(fiber.try()) // expect: 123 6 | System.print(fiber.isDone) // expect: true 7 | System.print(fiber.error) // expect: 123 8 | -------------------------------------------------------------------------------- /test/core/fiber/abort_null.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | Fiber.abort(null) 3 | System.print("get here") // expect: get here 4 | Fiber.yield("value") 5 | } 6 | 7 | System.print(fiber.try()) // expect: value 8 | System.print(fiber.isDone) // expect: false 9 | System.print(fiber.error) // expect: null 10 | -------------------------------------------------------------------------------- /test/core/fiber/call.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("fiber") 3 | } 4 | 5 | System.print("before") // expect: before 6 | fiber.call() // expect: fiber 7 | System.print("after") // expect: after 8 | -------------------------------------------------------------------------------- /test/core/fiber/call_direct_reenter.wren: -------------------------------------------------------------------------------- 1 | var fiber 2 | 3 | fiber = Fiber.new { 4 | fiber.call() // expect runtime error: Fiber has already been called. 5 | } 6 | 7 | fiber.call() 8 | -------------------------------------------------------------------------------- /test/core/fiber/call_done.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("call") 3 | } 4 | 5 | fiber.call() // expect: call 6 | fiber.call() // expect runtime error: Cannot call a finished fiber. 7 | -------------------------------------------------------------------------------- /test/core/fiber/call_error.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | Fiber.abort("Error!") 3 | System.print("should not get here") 4 | } 5 | 6 | fiber.try() 7 | fiber.call() // expect runtime error: Cannot call an aborted fiber. 8 | -------------------------------------------------------------------------------- /test/core/fiber/call_indirect_reenter.wren: -------------------------------------------------------------------------------- 1 | var a 2 | var b 3 | 4 | a = Fiber.new { 5 | b.call() // expect runtime error: Fiber has already been called. 6 | } 7 | 8 | b = Fiber.new { 9 | a.call() 10 | } 11 | 12 | b.call() 13 | -------------------------------------------------------------------------------- /test/core/fiber/call_return_implicit_null.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("fiber") // expect: fiber 3 | } 4 | 5 | System.print(fiber.call()) // expect: null 6 | -------------------------------------------------------------------------------- /test/core/fiber/call_return_value.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("fiber") 3 | return "result" // expect: fiber 4 | } 5 | 6 | System.print(fiber.call()) // expect: result 7 | -------------------------------------------------------------------------------- /test/core/fiber/call_root.wren: -------------------------------------------------------------------------------- 1 | var root = Fiber.current 2 | System.print("begin root") // expect: begin root 3 | 4 | Fiber.new { 5 | System.print("in new fiber") // expect: in new fiber 6 | root.call() // expect runtime error: Cannot call root fiber. 7 | System.print("called root") 8 | }.transfer() 9 | -------------------------------------------------------------------------------- /test/core/fiber/call_to_parameter.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new {|value| 2 | System.print(value) 3 | } 4 | 5 | System.print("before") // expect: before 6 | fiber.call() // expect: null 7 | System.print("after") // expect: after 8 | -------------------------------------------------------------------------------- /test/core/fiber/call_transferred.wren: -------------------------------------------------------------------------------- 1 | var main = Fiber.current 2 | 3 | var fiber = Fiber.new { 4 | System.print("transferred") 5 | System.print(main.transfer()) 6 | System.print("called") 7 | } 8 | 9 | fiber.transfer() // expect: transferred 10 | System.print("main") // expect: main 11 | fiber.call() // expect: null 12 | // expect: called 13 | -------------------------------------------------------------------------------- /test/core/fiber/call_with_value.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("fiber") 3 | } 4 | 5 | System.print("before") // expect: before 6 | fiber.call("value") // expect: fiber 7 | System.print("after") // expect: after 8 | -------------------------------------------------------------------------------- /test/core/fiber/call_with_value_direct_reenter.wren: -------------------------------------------------------------------------------- 1 | var fiber 2 | 3 | fiber = Fiber.new { 4 | fiber.call(2) // expect runtime error: Fiber has already been called. 5 | } 6 | 7 | fiber.call(1) 8 | -------------------------------------------------------------------------------- /test/core/fiber/call_with_value_done.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("call") 3 | } 4 | 5 | fiber.call(1) // expect: call 6 | fiber.call(2) // expect runtime error: Cannot call a finished fiber. 7 | -------------------------------------------------------------------------------- /test/core/fiber/call_with_value_error.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | Fiber.abort("Error!") 3 | System.print("should not get here") 4 | } 5 | 6 | fiber.try() 7 | fiber.call("value") // expect runtime error: Cannot call an aborted fiber. 8 | -------------------------------------------------------------------------------- /test/core/fiber/call_with_value_indirect_reenter.wren: -------------------------------------------------------------------------------- 1 | var A = Fiber.new { 2 | B.call(3) // expect runtime error: Fiber has already been called. 3 | } 4 | 5 | var B = Fiber.new { 6 | A.call(2) 7 | } 8 | 9 | B.call(1) 10 | -------------------------------------------------------------------------------- /test/core/fiber/call_with_value_to_parameter.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new {|value| 2 | System.print(value) 3 | } 4 | 5 | System.print("before") // expect: before 6 | fiber.call("value") // expect: value 7 | System.print("after") // expect: after 8 | -------------------------------------------------------------------------------- /test/core/fiber/error.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | "s".unknown 3 | } 4 | 5 | System.print(fiber.error) // expect: null 6 | System.print(fiber.try()) // expect: String does not implement 'unknown'. 7 | System.print(fiber.error) // expect: String does not implement 'unknown'. 8 | -------------------------------------------------------------------------------- /test/core/fiber/is_done.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("1") 3 | Fiber.yield() 4 | System.print("2") 5 | } 6 | 7 | System.print(fiber.isDone) // expect: false 8 | fiber.call() // expect: 1 9 | System.print(fiber.isDone) // expect: false 10 | fiber.call() // expect: 2 11 | System.print(fiber.isDone) // expect: true 12 | -------------------------------------------------------------------------------- /test/core/fiber/is_done_after_error.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | "s".unknown 3 | } 4 | 5 | fiber.try() 6 | System.print(fiber.isDone) // expect: true 7 | -------------------------------------------------------------------------------- /test/core/fiber/new_wrong_arg_type.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new("not fn") // expect runtime error: Argument must be a function. 2 | -------------------------------------------------------------------------------- /test/core/fiber/new_wrong_arity.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new {|a, b| null } // expect runtime error: Function cannot take more than one parameter. 2 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_direct_reenter.wren: -------------------------------------------------------------------------------- 1 | var F = Fiber.new { 2 | System.print(1) // expect: 1 3 | System.print(F.transfer()) // expect: null 4 | System.print(2) // expect: 2 5 | } 6 | 7 | F.call() 8 | // F remembers its original caller so transfers back to main. 9 | System.print(3) // expect: 3 10 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_error_not_string.wren: -------------------------------------------------------------------------------- 1 | var A = Fiber.new { 2 | B.transferError(123) 3 | } 4 | 5 | var B = Fiber.new { 6 | A.transfer() 7 | } 8 | 9 | B.try() 10 | System.print(B.error) // expect: 123 11 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_to_done.wren: -------------------------------------------------------------------------------- 1 | var a = Fiber.new { 2 | System.print("run") 3 | } 4 | 5 | a.call() // expect: run 6 | a.transfer() // expect runtime error: Cannot transfer to a finished fiber. 7 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_to_error.wren: -------------------------------------------------------------------------------- 1 | var a = Fiber.new { 2 | Fiber.abort("Error!") 3 | System.print("should not get here") 4 | } 5 | 6 | a.try() 7 | a.transfer() // expect runtime error: Cannot transfer to an aborted fiber. 8 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_to_yielded.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("called") 3 | System.print(Fiber.yield()) 4 | System.print("transferred") 5 | } 6 | 7 | fiber.call() // expect: called 8 | fiber.transfer() // expect: null 9 | // expect: transferred 10 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_with_value_direct_reenter.wren: -------------------------------------------------------------------------------- 1 | var F = Fiber.new { 2 | System.print(1) // expect: 1 3 | System.print(F.transfer("value")) // expect: value 4 | System.print(2) // expect: 2 5 | } 6 | 7 | F.call() 8 | System.print(3) // expect: 3 9 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_with_value_indirect_reenter.wren: -------------------------------------------------------------------------------- 1 | var A = Fiber.new { 2 | System.print(2) 3 | B.transfer("ignored") 4 | System.print("nope") 5 | } 6 | 7 | var B = Fiber.new { 8 | System.print(1) 9 | A.transfer("ignored") 10 | System.print(3) 11 | } 12 | 13 | B.call() 14 | // expect: 1 15 | // expect: 2 16 | // expect: 3 17 | System.print(4) // expect: 4 18 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_with_value_to_done.wren: -------------------------------------------------------------------------------- 1 | var a = Fiber.new { 2 | System.print("run") 3 | } 4 | 5 | a.call() // expect: run 6 | a.transfer("blah") // expect runtime error: Cannot transfer to a finished fiber. 7 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_with_value_to_error.wren: -------------------------------------------------------------------------------- 1 | var a = Fiber.new { 2 | Fiber.abort("Error!") 3 | System.print("should not get here") 4 | } 5 | 6 | a.try() 7 | a.transfer("blah") // expect runtime error: Cannot transfer to an aborted fiber. 8 | -------------------------------------------------------------------------------- /test/core/fiber/transfer_with_value_to_yielded.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("called") 3 | System.print(Fiber.yield()) 4 | System.print("transferred") 5 | } 6 | 7 | fiber.call() // expect: called 8 | fiber.transfer("value") // expect: value 9 | // expect: transferred 10 | -------------------------------------------------------------------------------- /test/core/fiber/try.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("before") 3 | true.unknownMethod 4 | System.print("after") 5 | } 6 | 7 | System.print(fiber.try()) 8 | // expect: before 9 | // expect: Bool does not implement 'unknownMethod'. 10 | System.print("after try") // expect: after try 11 | -------------------------------------------------------------------------------- /test/core/fiber/try_direct_reenter.wren: -------------------------------------------------------------------------------- 1 | var fiber 2 | 3 | fiber = Fiber.new { 4 | fiber.try() // expect runtime error: Fiber has already been called. 5 | } 6 | 7 | fiber.call() 8 | -------------------------------------------------------------------------------- /test/core/fiber/try_done.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("try") 3 | } 4 | 5 | fiber.try() // expect: try 6 | fiber.try() // expect runtime error: Cannot try a finished fiber. 7 | -------------------------------------------------------------------------------- /test/core/fiber/try_error.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("try") 3 | Fiber.abort("err") 4 | } 5 | 6 | fiber.try() // expect: try 7 | fiber.try() // expect runtime error: Cannot try an aborted fiber. 8 | -------------------------------------------------------------------------------- /test/core/fiber/try_indirect_reenter.wren: -------------------------------------------------------------------------------- 1 | var a 2 | var b 3 | 4 | a = Fiber.new { 5 | b.try() // expect runtime error: Fiber has already been called. 6 | } 7 | 8 | b = Fiber.new { 9 | a.call() 10 | } 11 | 12 | b.call() 13 | -------------------------------------------------------------------------------- /test/core/fiber/try_value.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new {|v| 2 | System.print("before") 3 | System.print(v) 4 | true.unknownMethod 5 | System.print("after") 6 | } 7 | 8 | System.print(fiber.try("value")) 9 | // expect: before 10 | // expect: value 11 | // expect: Bool does not implement 'unknownMethod'. 12 | System.print("after try") // expect: after try 13 | -------------------------------------------------------------------------------- /test/core/fiber/try_without_error.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("fiber") 3 | } 4 | 5 | System.print("before") // expect: before 6 | System.print(fiber.try()) // expect: fiber 7 | // expect: null 8 | System.print("after") // expect: after 9 | -------------------------------------------------------------------------------- /test/core/fiber/type.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new {} 2 | System.print(fiber is Fiber) // expect: true 3 | System.print(fiber is Object) // expect: true 4 | System.print(fiber is Bool) // expect: false 5 | System.print(fiber.type == Fiber) // expect: true 6 | -------------------------------------------------------------------------------- /test/core/fiber/yield_from_import_module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("module 1") 3 | Fiber.yield() 4 | System.print("module 2") 5 | -------------------------------------------------------------------------------- /test/core/fiber/yield_from_main.wren: -------------------------------------------------------------------------------- 1 | System.print("before") // expect: before 2 | Fiber.yield() 3 | System.print("not reached") 4 | -------------------------------------------------------------------------------- /test/core/fiber/yield_with_value_from_main.wren: -------------------------------------------------------------------------------- 1 | System.print("before") // expect: before 2 | Fiber.yield(1) 3 | System.print("not reached") -------------------------------------------------------------------------------- /test/core/function/arity.wren: -------------------------------------------------------------------------------- 1 | System.print(Fn.new {}.arity) // expect: 0 2 | System.print(Fn.new {|a| a}.arity) // expect: 1 3 | System.print(Fn.new {|a, b| a}.arity) // expect: 2 4 | System.print(Fn.new {|a, b, c| a}.arity) // expect: 3 5 | System.print(Fn.new {|a, b, c, d| a}.arity) // expect: 4 6 | -------------------------------------------------------------------------------- /test/core/function/call_missing_arguments.wren: -------------------------------------------------------------------------------- 1 | var f2 = Fn.new {|a, b| System.print(a + b) } 2 | f2.call("a") // expect runtime error: Function expects more arguments. 3 | -------------------------------------------------------------------------------- /test/core/function/call_runtime_error.wren: -------------------------------------------------------------------------------- 1 | var f1 = Fn.new {|a, b| a + b } // expect runtime error: Bool does not implement '+(_)'. 2 | f1.call(true, false) 3 | 4 | -------------------------------------------------------------------------------- /test/core/function/new_wrong_arg_type.wren: -------------------------------------------------------------------------------- 1 | Fn.new(3) // expect runtime error: Argument must be a function. 2 | -------------------------------------------------------------------------------- /test/core/function/to_string.wren: -------------------------------------------------------------------------------- 1 | System.print(Fn.new {}) // expect: 2 | -------------------------------------------------------------------------------- /test/core/function/type.wren: -------------------------------------------------------------------------------- 1 | System.print(Fn.new { 0 } is Fn) // expect: true 2 | System.print(Fn.new { 0 } is Object) // expect: true 3 | System.print(Fn.new { 0 } is String) // expect: false 4 | System.print(Fn.new { 0 }.type == Fn) // expect: true 5 | -------------------------------------------------------------------------------- /test/core/list/add.wren: -------------------------------------------------------------------------------- 1 | var a = [1] 2 | a.add(2) 3 | System.print(a) // expect: [1, 2] 4 | a.add(3) 5 | System.print(a) // expect: [1, 2, 3] 6 | 7 | // Returns added element. 8 | System.print(a.add(4)) // expect: 4 9 | -------------------------------------------------------------------------------- /test/core/list/add_all.wren: -------------------------------------------------------------------------------- 1 | var a = [1] 2 | a.addAll([2, 3]) 3 | System.print(a) // expect: [1, 2, 3] 4 | a.addAll([]) 5 | System.print(a) // expect: [1, 2, 3] 6 | a.addAll(4..6) 7 | System.print(a) // expect: [1, 2, 3, 4, 5, 6] 8 | 9 | // Returns argument. 10 | var range = 7..9 11 | System.print(a.addAll(range) == range) // expect: true 12 | -------------------------------------------------------------------------------- /test/core/list/clear.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.clear() 3 | System.print(a) // expect: [] 4 | System.print(a.count) // expect: 0 5 | 6 | // Returns null. 7 | System.print([1, 2].clear()) // expect: null 8 | -------------------------------------------------------------------------------- /test/core/list/contains.wren: -------------------------------------------------------------------------------- 1 | var list = [1, 2, 3, 4, "foo"] 2 | 3 | System.print(list.contains(2)) // expect: true 4 | System.print(list.contains(5)) // expect: false 5 | System.print(list.contains("foo")) // expect: true 6 | System.print(list.contains("bar")) // expect: false 7 | -------------------------------------------------------------------------------- /test/core/list/count.wren: -------------------------------------------------------------------------------- 1 | System.print([].count) // expect: 0 2 | System.print([1].count) // expect: 1 3 | System.print([1, 2, 3, 4].count) // expect: 4 4 | -------------------------------------------------------------------------------- /test/core/list/count_predicate.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | 3 | System.print(a.count {|x| x > 3 }) // expect: 0 4 | System.print(a.count {|x| x > 1 }) // expect: 2 5 | 6 | System.print([].count {|x| true }) // expect: 0 7 | -------------------------------------------------------------------------------- /test/core/list/count_predicate_non_bool_returning_fn.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | 3 | System.print(a.count {|x| "truthy" }) // expect: 3 4 | -------------------------------------------------------------------------------- /test/core/list/count_predicate_non_function_arg.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | 3 | a.count("string") // expect runtime error: String does not implement 'call(_)'. 4 | -------------------------------------------------------------------------------- /test/core/list/each.wren: -------------------------------------------------------------------------------- 1 | var words = "" 2 | ["One", "Two", "Three"].each {|word| words = words + word } 3 | System.print(words) // expect: OneTwoThree 4 | -------------------------------------------------------------------------------- /test/core/list/each_no_items.wren: -------------------------------------------------------------------------------- 1 | var i = 0 2 | [].each {|item| i = i + 1 } 3 | System.print(i) // expect: 0 4 | -------------------------------------------------------------------------------- /test/core/list/each_non_function_arg.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].each("string") // expect runtime error: String does not implement 'call(_)'. 2 | -------------------------------------------------------------------------------- /test/core/list/filled.wren: -------------------------------------------------------------------------------- 1 | var list = List.filled(3, "value") 2 | System.print(list.count) // expect: 3 3 | System.print(list) // expect: [value, value, value] 4 | 5 | // Can create an empty list. 6 | list = List.filled(0, "value") 7 | System.print(list.count) // expect: 0 8 | System.print(list) // expect: [] 9 | -------------------------------------------------------------------------------- /test/core/list/filled_size_negative.wren: -------------------------------------------------------------------------------- 1 | List.filled(-1, null) // expect runtime error: Size cannot be negative. 2 | -------------------------------------------------------------------------------- /test/core/list/filled_size_not_int.wren: -------------------------------------------------------------------------------- 1 | List.filled(1.2, null) // expect runtime error: Size must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/list/filled_size_not_num.wren: -------------------------------------------------------------------------------- 1 | List.filled("not num", null) // expect runtime error: Size must be a number. 2 | -------------------------------------------------------------------------------- /test/core/list/index_of.wren: -------------------------------------------------------------------------------- 1 | 2 | var list = [0, 1, 2, 3, 4] 3 | System.print(list.indexOf(4)) // expect: 4 4 | System.print(list.indexOf(2)) // expect: 2 5 | System.print(list.indexOf(3)) // expect: 3 6 | System.print(list.indexOf(0)) // expect: 0 7 | System.print(list.indexOf(100)) // expect: -1 8 | System.print(list.indexOf(-1)) // expect: -1 -------------------------------------------------------------------------------- /test/core/list/insert_index_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.insert(1.5, "value") // expect runtime error: Index must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/list/insert_index_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.insert("2", "value") // expect runtime error: Index must be a number. 3 | -------------------------------------------------------------------------------- /test/core/list/insert_index_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.insert(4, "value") // expect runtime error: Index out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/insert_index_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.insert(-5, "value") // expect runtime error: Index out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/iterate_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.iterate(1.5) // expect runtime error: Iterator must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/list/iterate_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.iterate("2") // expect runtime error: Iterator must be a number. 3 | -------------------------------------------------------------------------------- /test/core/list/iterator_value.wren: -------------------------------------------------------------------------------- 1 | var a = ["one", "two", "three", "four"] 2 | System.print(a.iteratorValue(0)) // expect: one 3 | System.print(a.iteratorValue(1)) // expect: two 4 | System.print(a.iteratorValue(2)) // expect: three 5 | System.print(a.iteratorValue(3)) // expect: four 6 | -------------------------------------------------------------------------------- /test/core/list/iterator_value_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.iteratorValue(1.5) // expect runtime error: Iterator must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/list/iterator_value_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.iteratorValue("2") // expect runtime error: Iterator must be a number. 3 | -------------------------------------------------------------------------------- /test/core/list/iterator_value_iterator_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.iteratorValue(4) // expect runtime error: Iterator out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/iterator_value_iterator_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.iteratorValue(-5) // expect runtime error: Iterator out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/join_separator_not_string.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].join(2) // expect runtime error: Right operand must be a string. 2 | -------------------------------------------------------------------------------- /test/core/list/map.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | var b = a.map {|x| x + 1 }.toList 3 | System.print(b) // expect: [2, 3, 4] 4 | -------------------------------------------------------------------------------- /test/core/list/multiply.wren: -------------------------------------------------------------------------------- 1 | System.print([1, 2, 3] * 0) // expect: [] 2 | System.print([1, 2, 3] * 1) // expect: [1, 2, 3] 3 | System.print([1, 2, 3] * 4) // expect: [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3] 4 | 5 | // Doesn't modify original list. 6 | var a = [1, 2, 3] 7 | a * 5 8 | System.print(a) // expect: [1, 2, 3] 9 | -------------------------------------------------------------------------------- /test/core/list/multiply_negative.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3] * -3 // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/list/multiply_not_int.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3] * 1.2 // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/list/multiply_not_num.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3] * "not num" // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/list/new.wren: -------------------------------------------------------------------------------- 1 | var list = List.new() 2 | 3 | System.print(list.count) // expect: 0 4 | System.print(list) // expect: [] 5 | list.add(1) 6 | System.print(list) // expect: [1] 7 | -------------------------------------------------------------------------------- /test/core/list/not.wren: -------------------------------------------------------------------------------- 1 | System.print(![1, 2]) // expect: false 2 | System.print(![]) // expect: false 3 | -------------------------------------------------------------------------------- /test/core/list/plus_not_iterable.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3] + 4 // expect runtime error: Num does not implement 'iterate(_)'. 2 | -------------------------------------------------------------------------------- /test/core/list/reduce_no_items.wren: -------------------------------------------------------------------------------- 1 | [].reduce {|a, b| 1 } // expect runtime error: Can't reduce an empty sequence. 2 | -------------------------------------------------------------------------------- /test/core/list/reduce_single_item.wren: -------------------------------------------------------------------------------- 1 | System.print([1].reduce {|a, b| 42 }) // expect: 1 2 | System.print([].reduce(1) {|a, b| 42 }) // expect: 1 3 | -------------------------------------------------------------------------------- /test/core/list/reduce_wrong_arity.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].reduce {|x, y, z| x } // expect runtime error: Function expects more arguments. 2 | -------------------------------------------------------------------------------- /test/core/list/remove_at_index_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.removeAt(1.5) // expect runtime error: Index must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/list/remove_at_index_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.removeAt("2") // expect runtime error: Index must be a number. 3 | -------------------------------------------------------------------------------- /test/core/list/remove_at_index_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.removeAt(4) // expect runtime error: Index out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/remove_at_index_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a.removeAt(-5) // expect runtime error: Index out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/sort.wren: -------------------------------------------------------------------------------- 1 | System.print([4, 1, 3, 2].sort()) // expect: [1, 2, 3, 4] 2 | 3 | var l = [10, 7, 8, 9, 1, 5] 4 | l.sort{|a, b| a < b } 5 | System.print(l) // expect: [1, 5, 7, 8, 9, 10] 6 | l.sort{|a, b| a > b } 7 | System.print(l) // expect: [10, 9, 8, 7, 5, 1] 8 | 9 | [10, 7, 8, 9, 1, 5].sort(3) // expect runtime error: Comparer must be a function. -------------------------------------------------------------------------------- /test/core/list/subscript_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[1.5] // expect runtime error: Subscript must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_range_from_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[1.5..2] // expect runtime error: Range start must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_range_from_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[3..2] // expect runtime error: Range start out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_range_from_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[-4..2] // expect runtime error: Range start out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_range_to_exclusive_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[1...4] // expect runtime error: Range end out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_range_to_exclusive_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[0...-5] // expect runtime error: Range end out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_range_to_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[1..2.5] // expect runtime error: Range end must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_range_to_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[1..3] // expect runtime error: Range end out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_range_to_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[0..-4] // expect runtime error: Range end out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_setter_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[1.5] = 1 // expect runtime error: Subscript must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_setter_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a["2"] = 1 // expect runtime error: Subscript must be a number. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_setter_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[4] = 1 // expect runtime error: Subscript out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_setter_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[-5] = 1 // expect runtime error: Subscript out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[4] // expect runtime error: Subscript out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a[-5] // expect runtime error: Subscript out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/list/subscript_wrong_type.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | a["2"] // expect runtime error: Subscript must be a number or a range. 3 | -------------------------------------------------------------------------------- /test/core/list/swap.wren: -------------------------------------------------------------------------------- 1 | var list = [0, 1, 2, 3, 4] 2 | 3 | list.swap(0, 3) 4 | System.print(list) // expect: [3, 1, 2, 0, 4] 5 | 6 | list.swap(-1, 2) 7 | System.print(list) // expect: [3, 1, 4, 0, 2] 8 | 9 | list.swap(8, 0) // expect runtime error: Index 0 out of bounds. -------------------------------------------------------------------------------- /test/core/list/type.wren: -------------------------------------------------------------------------------- 1 | System.print([] is List) // expect: true 2 | System.print([] is Sequence) // expect: true 3 | System.print([] is Object) // expect: true 4 | System.print([] is Bool) // expect: false 5 | System.print([].type == List) // expect: true 6 | -------------------------------------------------------------------------------- /test/core/list/where.wren: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3] 2 | var b = a.where {|x| x > 1 }.toList 3 | System.print(b) // expect: [2, 3] 4 | 5 | var c = a.where {|x| x > 10 }.toList 6 | System.print(c) // expect: [] 7 | -------------------------------------------------------------------------------- /test/core/map/churn.wren: -------------------------------------------------------------------------------- 1 | // This is a regression test for a bug where inserting in a map would not 2 | // correctly reuse tombstone entries, eventually deadlocking on insert. 3 | var map = {} 4 | 5 | for (i in 0...100) { 6 | map[i] = i 7 | 8 | if (i >= 10) map.remove(i - 10) 9 | } 10 | 11 | System.print(map.count) // expect: 10 12 | -------------------------------------------------------------------------------- /test/core/map/clear.wren: -------------------------------------------------------------------------------- 1 | var a = {1: 1, 2: 2, 3: 3} 2 | a.clear() 3 | System.print(a) // expect: {} 4 | System.print(a.count) // expect: 0 5 | 6 | // Returns null. 7 | System.print({1: 2}.clear()) // expect: null 8 | -------------------------------------------------------------------------------- /test/core/map/contains_key_not_value.wren: -------------------------------------------------------------------------------- 1 | var result = {}.containsKey([]) // expect runtime error: Key must be a value type. 2 | -------------------------------------------------------------------------------- /test/core/map/empty_string_key.wren: -------------------------------------------------------------------------------- 1 | var map = { 2 | "": "empty string" 3 | } 4 | 5 | System.print(map[""]) // expect: empty string 6 | -------------------------------------------------------------------------------- /test/core/map/is_empty.wren: -------------------------------------------------------------------------------- 1 | System.print({}.isEmpty) // expect: true 2 | System.print({1: 1}.isEmpty) // expect: false 3 | -------------------------------------------------------------------------------- /test/core/map/iterate_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = {1: 2, 3: 4} 2 | a.iterate(1.5) // expect runtime error: Iterator must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/map/iterate_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = {1: 2, 3: 4} 2 | a.iterate("2") // expect runtime error: Iterator must be a number. 3 | -------------------------------------------------------------------------------- /test/core/map/iterator_value_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = {1: "one"} 2 | a.iteratorValue(1.5) // expect runtime error: Iterator must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/map/iterator_value_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = {1: "one"} 2 | a.iteratorValue("2") // expect runtime error: Iterator must be a number. 3 | -------------------------------------------------------------------------------- /test/core/map/iterator_value_iterator_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = {1: "one"} 2 | 3 | // The maximum value is based on the map's capacity, not its count, so use a 4 | // sufficiently large enough value for the test to make not affected by growth 5 | // strategy. 6 | a.iteratorValue(9999) // expect runtime error: Iterator out of bounds. 7 | -------------------------------------------------------------------------------- /test/core/map/iterator_value_iterator_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = {1: "one"} 2 | 3 | // The maximum value is based on the map's capacity, not its count, so use a 4 | // sufficiently large enough value for the test to make not affected by growth 5 | // strategy. 6 | a.iteratorValue(-9999) // expect runtime error: Iterator out of bounds. 7 | -------------------------------------------------------------------------------- /test/core/map/key_iterate_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = {1: 2, 3: 4} 2 | a.keys.iterate(1.5) // expect runtime error: Iterator must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/map/key_iterate_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = {1: 2, 3: 4} 2 | a.keys.iterate("2") // expect runtime error: Iterator must be a number. 3 | -------------------------------------------------------------------------------- /test/core/map/new.wren: -------------------------------------------------------------------------------- 1 | var map = Map.new() 2 | 3 | System.print(map.count) // expect: 0 4 | System.print(map) // expect: {} 5 | -------------------------------------------------------------------------------- /test/core/map/remove_key_not_value.wren: -------------------------------------------------------------------------------- 1 | var result = {}.remove([]) // expect runtime error: Key must be a value type. 2 | -------------------------------------------------------------------------------- /test/core/map/reuse_tombstone.wren: -------------------------------------------------------------------------------- 1 | // Regression test for #373. 2 | var map = {} 3 | map[2] = "two" 4 | map[0] = "zero" 5 | map.remove(2) 6 | map[0] = "zero again" 7 | map.remove(0) 8 | 9 | System.print(map.containsKey(0)) // expect: false 10 | -------------------------------------------------------------------------------- /test/core/map/subscript_empty_map.wren: -------------------------------------------------------------------------------- 1 | // This is a regression test to ensure map handles a null entry array. 2 | 3 | var map = {} 4 | System.print(map["key"]) // expect: null 5 | -------------------------------------------------------------------------------- /test/core/map/subscript_key_not_value.wren: -------------------------------------------------------------------------------- 1 | var result = {}[[]] // expect runtime error: Key must be a value type. 2 | -------------------------------------------------------------------------------- /test/core/map/subscript_setter_key_not_value.wren: -------------------------------------------------------------------------------- 1 | var result = {}[[]] = "value" // expect runtime error: Key must be a value type. 2 | -------------------------------------------------------------------------------- /test/core/map/type.wren: -------------------------------------------------------------------------------- 1 | System.print({} is Map) // expect: true 2 | // TODO: Abstract base class for associations. 3 | System.print({} is Object) // expect: true 4 | System.print({} is Bool) // expect: false 5 | System.print({}.type == Map) // expect: true 6 | -------------------------------------------------------------------------------- /test/core/map/value_iterate_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = {1: 2, 3: 4} 2 | a.values.iterate(1.5) // expect runtime error: Iterator must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/map/value_iterate_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = {1: 2, 3: 4} 2 | a.values.iterate("2") // expect runtime error: Iterator must be a number. 3 | -------------------------------------------------------------------------------- /test/core/map_entry/new.wren: -------------------------------------------------------------------------------- 1 | var entry = MapEntry.new("key", "value") 2 | 3 | System.print(entry.key) // expect: key 4 | System.print(entry.value) // expect: value 5 | -------------------------------------------------------------------------------- /test/core/null/no_constructor.wren: -------------------------------------------------------------------------------- 1 | Null.new() // expect runtime error: Null metaclass does not implement 'new()'. 2 | -------------------------------------------------------------------------------- /test/core/null/not.wren: -------------------------------------------------------------------------------- 1 | System.print(!null) // expect: true 2 | -------------------------------------------------------------------------------- /test/core/null/type.wren: -------------------------------------------------------------------------------- 1 | System.print(null is Null) // expect: true 2 | System.print(null is Object) // expect: true 3 | System.print(null is Bool) // expect: false 4 | System.print(null.type == Null) // expect: true 5 | -------------------------------------------------------------------------------- /test/core/number/abs.wren: -------------------------------------------------------------------------------- 1 | System.print(123.abs) // expect: 123 2 | System.print((-123).abs) // expect: 123 3 | System.print(0.abs) // expect: 0 4 | System.print((-0).abs) // expect: 0 5 | System.print((-0.12).abs) // expect: 0.12 6 | System.print(12.34.abs) // expect: 12.34 7 | -------------------------------------------------------------------------------- /test/core/number/acos.wren: -------------------------------------------------------------------------------- 1 | System.print(0.acos) // expect: 1.5707963267949 2 | System.print(1.acos) // expect: 0 3 | System.print((-1).acos) // expect: 3.1415926535898 4 | -------------------------------------------------------------------------------- /test/core/number/asin.wren: -------------------------------------------------------------------------------- 1 | System.print(0.asin) // expect: 0 2 | System.print(1.asin) // expect: 1.5707963267949 3 | System.print((-1).asin) // expect: -1.5707963267949 4 | -------------------------------------------------------------------------------- /test/core/number/atan.wren: -------------------------------------------------------------------------------- 1 | System.print(0.atan) // expect: 0 2 | System.print(1.atan) // expect: 0.78539816339745 3 | -------------------------------------------------------------------------------- /test/core/number/atan2.wren: -------------------------------------------------------------------------------- 1 | System.print(0.atan(0)) // expect: 0 2 | System.print(0.atan(1)) // expect: 0 3 | 4 | System.print(1.atan(0)) // expect: 1.5707963267949 5 | -------------------------------------------------------------------------------- /test/core/number/atan2_x_not_num.wren: -------------------------------------------------------------------------------- 1 | 0.atan(false) // expect runtime error: x value must be a number. -------------------------------------------------------------------------------- /test/core/number/bitwise_and_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 & false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/bitwise_lsh_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 << false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/bitwise_or_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 | false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/bitwise_rsh_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 >> false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/bitwise_xor_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 ^ false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/cbrt.wren: -------------------------------------------------------------------------------- 1 | System.print(8.cbrt) // expect: 2 2 | System.print(1000000.cbrt) // expect: 100 3 | System.print(1.cbrt) // expect: 1 4 | System.print((-0).cbrt) // expect: -0 5 | System.print(0.cbrt) // expect: 0 6 | System.print(-2.cbrt) // expect: -1.2599210498949 7 | -------------------------------------------------------------------------------- /test/core/number/clamp.wren: -------------------------------------------------------------------------------- 1 | var num = 4 2 | 3 | System.print(num.clamp(0, 10)) // expect: 4 4 | System.print(num.clamp(0, 1)) // expect: 1 5 | System.print(2.clamp(0, 1)) // expect: 1 6 | System.print((-1).clamp(0, 1)) // expect: 0 7 | System.print((-1).clamp(-20, 0)) // expect: -1 8 | -------------------------------------------------------------------------------- /test/core/number/clamp_max_not_num.wren: -------------------------------------------------------------------------------- 1 | 1.clamp(0, false) // expect runtime error: Max value must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/clamp_min_not_num.wren: -------------------------------------------------------------------------------- 1 | 1.clamp(false, 2) // expect runtime error: Min value must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/cos.wren: -------------------------------------------------------------------------------- 1 | System.print(0.cos) // expect: 1 2 | System.print(Num.pi.cos) // expect: -1 3 | System.print((2 * Num.pi).cos) // expect: 1 4 | 5 | // this should of course be 0, but it's not that precise 6 | System.print((Num.pi / 2).cos.abs < 1.0e-16) // expect: true 7 | -------------------------------------------------------------------------------- /test/core/number/decimal_point_at_eof.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | 123. -------------------------------------------------------------------------------- /test/core/number/divide_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 / false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/exp.wren: -------------------------------------------------------------------------------- 1 | System.print(5.exp) // expect: 148.41315910258 2 | System.print(10.exp) // expect: 22026.465794807 3 | System.print((-1).exp) // expect: 0.36787944117144 4 | -------------------------------------------------------------------------------- /test/core/number/from_string_not_string.wren: -------------------------------------------------------------------------------- 1 | Num.fromString(1) // expect runtime error: Argument must be a string. -------------------------------------------------------------------------------- /test/core/number/greater_than_equal_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 >= false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/greater_than_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 > false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/invalid_hex_literal.wren: -------------------------------------------------------------------------------- 1 | var x = 2xFF // expect error 2 | -------------------------------------------------------------------------------- /test/core/number/is_infinity.wren: -------------------------------------------------------------------------------- 1 | System.print(123.isInfinity) // expect: false 2 | System.print((1/0).isInfinity) // expect: true 3 | System.print((-10/0).isInfinity) // expect: true 4 | -------------------------------------------------------------------------------- /test/core/number/is_nan.wren: -------------------------------------------------------------------------------- 1 | System.print(1.isNan) // expect: false 2 | System.print((0/0).isNan) // expect: true 3 | 4 | // Infinity is not NaN. 5 | System.print((1/0).isNan) // expect: false 6 | -------------------------------------------------------------------------------- /test/core/number/largest.wren: -------------------------------------------------------------------------------- 1 | System.print(Num.largest) // expect: 1.7976931348623e+308 2 | -------------------------------------------------------------------------------- /test/core/number/less_than_equal_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 <= false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/less_than_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 < false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/log.wren: -------------------------------------------------------------------------------- 1 | System.print(3.log) // expect: 1.0986122886681 2 | System.print(100.log) // expect: 4.6051701859881 3 | System.print((-1).log) // expect: nan 4 | -------------------------------------------------------------------------------- /test/core/number/log2.wren: -------------------------------------------------------------------------------- 1 | System.print(1024.log2) // expect: 10 2 | System.print(2048.log2) // expect: 11 3 | System.print(100.log2) // expect: 6.6438561897747 4 | System.print((-1).log2) // expect: nan 5 | -------------------------------------------------------------------------------- /test/core/number/maxSafeInteger.wren: -------------------------------------------------------------------------------- 1 | System.print(Num.maxSafeInteger) // expect: 9.007199254741e+15 2 | -------------------------------------------------------------------------------- /test/core/number/max_other_not_num.wren: -------------------------------------------------------------------------------- 1 | 1.max(false) // expect runtime error: Other value must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/minSafeInteger.wren: -------------------------------------------------------------------------------- 1 | System.print(Num.minSafeInteger) // expect: -9.007199254741e+15 2 | -------------------------------------------------------------------------------- /test/core/number/min_max.wren: -------------------------------------------------------------------------------- 1 | var num = 4 2 | var num2 = 6 3 | 4 | System.print(num.max(num2)) // expect: 6 5 | System.print(num.min(num2)) // expect: 4 -------------------------------------------------------------------------------- /test/core/number/min_other_not_num.wren: -------------------------------------------------------------------------------- 1 | 1.min(false) // expect runtime error: Other value must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/minus.wren: -------------------------------------------------------------------------------- 1 | // Infix. 2 | System.print(5 - 3) // expect: 2 3 | System.print(3.1 - 0.24) // expect: 2.86 4 | System.print(3 - 2 - 1) // expect: 0 5 | 6 | // Unary negation. 7 | var a = 3 8 | System.print(-a) // expect: -3 9 | -------------------------------------------------------------------------------- /test/core/number/minus_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 - false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/mod_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 % false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/multiply.wren: -------------------------------------------------------------------------------- 1 | System.print(5 * 3) // expect: 15 2 | System.print(12.34 * 0.3) // expect: 3.702 3 | -------------------------------------------------------------------------------- /test/core/number/multiply_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 * false // expect runtime error: Right operand must be a number. 2 | -------------------------------------------------------------------------------- /test/core/number/no_constructor.wren: -------------------------------------------------------------------------------- 1 | Num.new() // expect runtime error: Num metaclass does not implement 'new()'. 2 | -------------------------------------------------------------------------------- /test/core/number/not.wren: -------------------------------------------------------------------------------- 1 | System.print(!123) // expect: false 2 | System.print(!0) // expect: false 3 | -------------------------------------------------------------------------------- /test/core/number/plus.wren: -------------------------------------------------------------------------------- 1 | System.print(1 + 2) // expect: 3 2 | System.print(12.34 + 0.13) // expect: 12.47 3 | System.print(3 + 5 + 2) // expect: 10 4 | -------------------------------------------------------------------------------- /test/core/number/plus_operand_not_num.wren: -------------------------------------------------------------------------------- 1 | 1 + false // expect runtime error: Right operand must be a number. 2 | 3 | // TODO: What about a string on the RHS? 4 | -------------------------------------------------------------------------------- /test/core/number/pow.wren: -------------------------------------------------------------------------------- 1 | System.print(2.pow(4)) // expect: 16 2 | System.print(2.pow(10)) // expect: 1024 3 | 4 | System.print(1.pow(0)) // expect: 1 5 | -------------------------------------------------------------------------------- /test/core/number/pow_power_not_num.wren: -------------------------------------------------------------------------------- 1 | 1.pow(false) // expect runtime error: Power value must be a number. 2 | 3 | -------------------------------------------------------------------------------- /test/core/number/sign.wren: -------------------------------------------------------------------------------- 1 | System.print(123.sign) // expect: 1 2 | System.print((-123).sign) // expect: -1 3 | System.print(0.sign) // expect: 0 4 | System.print((-0).sign) // expect: 0 5 | System.print(0.123.sign) // expect: 1 6 | System.print((-0.123).sign) // expect: -1 7 | -------------------------------------------------------------------------------- /test/core/number/sin.wren: -------------------------------------------------------------------------------- 1 | System.print(0.sin) // expect: 0 2 | System.print((Num.pi / 2).sin) // expect: 1 3 | 4 | // these should of course be 0, but it's not that precise 5 | System.print(Num.pi.sin.abs < 1.0e-15) // expect: true 6 | System.print((2 * Num.pi).sin.abs < 1.0e-15) // expect: true 7 | -------------------------------------------------------------------------------- /test/core/number/smallest.wren: -------------------------------------------------------------------------------- 1 | System.print(Num.smallest) // expect: 2.2250738585072e-308 2 | -------------------------------------------------------------------------------- /test/core/number/tan.wren: -------------------------------------------------------------------------------- 1 | System.print(0.tan) // expect: 0 2 | System.print((Num.pi / 4).tan) // expect: 1 3 | System.print((-Num.pi / 4).tan) // expect: -1 4 | -------------------------------------------------------------------------------- /test/core/number/to_string.wren: -------------------------------------------------------------------------------- 1 | System.print(123.toString == "123") // expect: true 2 | System.print((-123).toString == "-123") // expect: true 3 | System.print((-0).toString == "-0") // expect: true 4 | System.print(12.34.toString == "12.34") // expect: true 5 | System.print((-0.0001).toString == "-0.0001") // expect: true 6 | -------------------------------------------------------------------------------- /test/core/number/type.wren: -------------------------------------------------------------------------------- 1 | System.print(123 is Num) // expect: true 2 | System.print(123 is Object) // expect: true 3 | System.print(123 is String) // expect: false 4 | System.print(123.type == Num) // expect: true 5 | -------------------------------------------------------------------------------- /test/core/object/no_constructor.wren: -------------------------------------------------------------------------------- 1 | Object.new() // expect runtime error: Object metaclass does not implement 'new()'. 2 | -------------------------------------------------------------------------------- /test/core/object/nonclass_on_right.wren: -------------------------------------------------------------------------------- 1 | 1 is false // expect runtime error: Right operand must be a class. 2 | -------------------------------------------------------------------------------- /test/core/object/not.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | } 4 | System.print(!Foo.new()) // expect: false 5 | -------------------------------------------------------------------------------- /test/core/object/to_string.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | } 4 | System.print(Foo.new().toString == "instance of Foo") // expect: true 5 | -------------------------------------------------------------------------------- /test/core/range/exclusive_range_wrong_rhs_type.wren: -------------------------------------------------------------------------------- 1 | 1..."s" // expect runtime error: Right hand side of range must be a number. 2 | -------------------------------------------------------------------------------- /test/core/range/inclusive_range_wrong_rhs_type.wren: -------------------------------------------------------------------------------- 1 | 1.."s" // expect runtime error: Right hand side of range must be a number. 2 | -------------------------------------------------------------------------------- /test/core/range/is_inclusive.wren: -------------------------------------------------------------------------------- 1 | System.print((0..0).isInclusive) // expect: true 2 | System.print((0...0).isInclusive) // expect: false 3 | 4 | System.print((-1..1).isInclusive) // expect: true 5 | System.print((-1...1).isInclusive) // expect: false 6 | -------------------------------------------------------------------------------- /test/core/range/iterate_wrong_type.wren: -------------------------------------------------------------------------------- 1 | (1..3).iterate("") // expect runtime error: Iterator must be a number. 2 | -------------------------------------------------------------------------------- /test/core/range/join.wren: -------------------------------------------------------------------------------- 1 | var a = 1..3 2 | 3 | System.print(a.join()) // expect: 123 4 | System.print(a.join(", ")) // expect: 1, 2, 3 5 | -------------------------------------------------------------------------------- /test/core/range/join_separator_not_string.wren: -------------------------------------------------------------------------------- 1 | (1..3).join(2) // expect runtime error: Right operand must be a string. 2 | -------------------------------------------------------------------------------- /test/core/range/map.wren: -------------------------------------------------------------------------------- 1 | var a = 1..3 2 | var b = a.map {|x| x + 1 }.toList 3 | System.print(b) // expect: [2, 3, 4] 4 | -------------------------------------------------------------------------------- /test/core/range/no_constructor.wren: -------------------------------------------------------------------------------- 1 | Range.new() // expect runtime error: Range metaclass does not implement 'new()'. 2 | -------------------------------------------------------------------------------- /test/core/range/reduce.wren: -------------------------------------------------------------------------------- 1 | var range = 1..10 2 | 3 | System.print(range.reduce {|a, b| a + b }) // expect: 55 4 | System.print(range.reduce(100) {|a, b| a < b ? a : b }) // expect: 1 5 | -------------------------------------------------------------------------------- /test/core/range/to_string.wren: -------------------------------------------------------------------------------- 1 | System.print(1..3) // expect: 1..3 2 | System.print(12345.6789..12345.6789) // expect: 12345.6789..12345.6789 3 | System.print(-100..-300) // expect: -100..-300 4 | 5 | System.print(1...3) // expect: 1...3 6 | System.print(12345.6789...12345.6789) // expect: 12345.6789...12345.6789 7 | System.print(-100...-300) // expect: -100...-300 8 | -------------------------------------------------------------------------------- /test/core/range/type.wren: -------------------------------------------------------------------------------- 1 | var range = 2..5 2 | 3 | System.print(range is Range) // expect: true 4 | System.print(range is Sequence) // expect: true 5 | System.print(range is Object) // expect: true 6 | System.print(range is String) // expect: false 7 | System.print(range.type == Range) // expect: true 8 | -------------------------------------------------------------------------------- /test/core/range/where.wren: -------------------------------------------------------------------------------- 1 | var a = 1..3 2 | var b = a.where {|x| x > 1 }.toList 3 | System.print(b) // expect: [2, 3] 4 | 5 | var c = a.where {|x| x > 10 }.toList 6 | System.print(c) // expect: [] 7 | -------------------------------------------------------------------------------- /test/core/sequence/all_non_function_arg.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].all("string") // expect runtime error: String does not implement 'call(_)'. -------------------------------------------------------------------------------- /test/core/sequence/any_non_function_arg.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].any("string") // expect runtime error: String does not implement 'call(_)'. 2 | -------------------------------------------------------------------------------- /test/core/sequence/count.wren: -------------------------------------------------------------------------------- 1 | class TestSequence is Sequence { 2 | construct new() {} 3 | 4 | iterate(iterator) { 5 | if (iterator == null) return 1 6 | if (iterator == 10) return false 7 | return iterator + 1 8 | } 9 | 10 | iteratorValue(iterator) { iterator } 11 | } 12 | 13 | System.print(TestSequence.new().count) // expect: 10 14 | -------------------------------------------------------------------------------- /test/core/sequence/no_constructor.wren: -------------------------------------------------------------------------------- 1 | Sequence.new() // expect runtime error: Sequence metaclass does not implement 'new()'. 2 | -------------------------------------------------------------------------------- /test/core/sequence/skip_negative.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].skip(-1) // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/sequence/skip_not_int.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].skip(1.2) // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/sequence/skip_not_num.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].skip("s") // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/sequence/take_negative.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].take(-1) // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/sequence/take_not_int.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].take(1.2) // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/sequence/take_not_num.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 3].take("s") // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/sequence/to_list.wren: -------------------------------------------------------------------------------- 1 | class TestSequence is Sequence { 2 | construct new() {} 3 | 4 | iterate(iterator) { 5 | if (iterator == null) return 1 6 | if (iterator == 3) return false 7 | return iterator + 1 8 | } 9 | 10 | iteratorValue(iterator) { iterator } 11 | } 12 | 13 | System.print(TestSequence.new().toList) // expect: [1, 2, 3] 14 | -------------------------------------------------------------------------------- /test/core/string/bytes.wren: -------------------------------------------------------------------------------- 1 | // Bytes: 11111 2 | // 012345678901234 3 | // Chars: sø mé ஃ thî ng 4 | var s = "søméஃthîng" 5 | 6 | System.print(s.bytes is StringByteSequence) // expect: true 7 | -------------------------------------------------------------------------------- /test/core/string/concatenation.wren: -------------------------------------------------------------------------------- 1 | System.print("a" + "b") // expect: ab 2 | 3 | // 8-bit clean. 4 | System.print(("a\0b" + "\0c") == "a\0b\0c") // expect: true 5 | -------------------------------------------------------------------------------- /test/core/string/concatenation_wrong_arg_type.wren: -------------------------------------------------------------------------------- 1 | System.print("a" + 123) // expect runtime error: Right operand must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/contains_argument_not_string.wren: -------------------------------------------------------------------------------- 1 | "foo".contains(1) // expect runtime error: Argument must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/ends_with_invalid_arg.wren: -------------------------------------------------------------------------------- 1 | System.print("abcd".endsWith(null)) // expect runtime error: Argument must be a string. -------------------------------------------------------------------------------- /test/core/string/from_byte.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromByte(65)) // expect: A 2 | System.print(String.fromByte(0).bytes[0]) // expect: 0 3 | System.print(String.fromByte(255).bytes[0]) // expect: 255 4 | -------------------------------------------------------------------------------- /test/core/string/from_byte_not_int.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromByte(12.34)) // expect runtime error: Byte must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string/from_byte_not_num.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromByte("not num")) // expect runtime error: Byte must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string/from_byte_too_large.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromByte(0xff + 1)) // expect runtime error: Byte cannot be greater than 0xff. 2 | -------------------------------------------------------------------------------- /test/core/string/from_byte_too_small.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromByte(-1)) // expect runtime error: Byte cannot be negative. 2 | -------------------------------------------------------------------------------- /test/core/string/from_code_point.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromCodePoint(65)) // expect: A 2 | System.print(String.fromCodePoint(164)) // expect: ¤ 3 | System.print(String.fromCodePoint(398)) // expect: Ǝ 4 | System.print(String.fromCodePoint(8225)) // expect: ‡ 5 | System.print(String.fromCodePoint(0x254b)) // expect: ╋ 6 | -------------------------------------------------------------------------------- /test/core/string/from_code_point_not_int.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromCodePoint(12.34)) // expect runtime error: Code point must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string/from_code_point_not_num.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromCodePoint("not num")) // expect runtime error: Code point must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string/from_code_point_too_large.wren: -------------------------------------------------------------------------------- 1 | // UTF-8 mandates that only values up to 10ffff can be encoded. 2 | // See: http://tools.ietf.org/html/rfc3629 3 | System.print(String.fromCodePoint(0x10ffff + 1)) // expect runtime error: Code point cannot be greater than 0x10ffff. 4 | -------------------------------------------------------------------------------- /test/core/string/from_code_point_too_small.wren: -------------------------------------------------------------------------------- 1 | System.print(String.fromCodePoint(-1)) // expect runtime error: Code point cannot be negative. 2 | -------------------------------------------------------------------------------- /test/core/string/index_of_invalid_arg.wren: -------------------------------------------------------------------------------- 1 | System.print("abcd".indexOf(null)) // expect runtime error: Argument must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/index_of_start_not_int.wren: -------------------------------------------------------------------------------- 1 | "abcd".indexOf("bc", 12.34) // expect runtime error: Start must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string/index_of_start_not_num.wren: -------------------------------------------------------------------------------- 1 | "abcd".indexOf("bc", "not num") // expect runtime error: Start must be a number. 2 | System.print("after") -------------------------------------------------------------------------------- /test/core/string/index_of_start_too_large.wren: -------------------------------------------------------------------------------- 1 | "abcd".indexOf("bc", 4) // expect runtime error: Start out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string/index_of_start_too_small.wren: -------------------------------------------------------------------------------- 1 | "abcd".indexOf("bc", -5) // expect runtime error: Start out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string/iterate_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | "s".iterate(1.5) // expect runtime error: Iterator must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string/iterate_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | "s".iterate("2") // expect runtime error: Iterator must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string/iterator_value_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | "s".iteratorValue(1.5) // expect runtime error: Iterator must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string/iterator_value_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | "s".iteratorValue("2") // expect runtime error: Iterator must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string/iterator_value_iterator_too_large.wren: -------------------------------------------------------------------------------- 1 | "123".iteratorValue(4) // expect runtime error: Iterator out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string/iterator_value_iterator_too_small.wren: -------------------------------------------------------------------------------- 1 | "123".iteratorValue(-5) // expect runtime error: Iterator out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string/join.wren: -------------------------------------------------------------------------------- 1 | var str = "string" 2 | 3 | System.print(str.join("") == str) // expect: true 4 | 5 | System.print(str.join(", ")) // expect: s, t, r, i, n, g 6 | 7 | // 8-bit clean. 8 | var ing = "a\0b\0c" 9 | System.print(ing.join("") == ing) // expect: true 10 | System.print(ing.join(", ") == "a, \0, b, \0, c") // expect: true 11 | -------------------------------------------------------------------------------- /test/core/string/join_separator_not_string.wren: -------------------------------------------------------------------------------- 1 | "string".join(2) // // expect runtime error: Right operand must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/multiply.wren: -------------------------------------------------------------------------------- 1 | System.print("|" + "abc" * 0 + "|") // expect: || 2 | System.print("abc" * 1) // expect: abc 3 | System.print("abc" * 4) // expect: abcabcabcabc 4 | -------------------------------------------------------------------------------- /test/core/string/multiply_negative.wren: -------------------------------------------------------------------------------- 1 | "abc" * -3 // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/string/multiply_not_int.wren: -------------------------------------------------------------------------------- 1 | "abc" * 1.2 // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/string/multiply_not_num.wren: -------------------------------------------------------------------------------- 1 | "abc" * "not num" // expect runtime error: Count must be a non-negative integer. 2 | -------------------------------------------------------------------------------- /test/core/string/no_constructor.wren: -------------------------------------------------------------------------------- 1 | String.new() // expect runtime error: String metaclass does not implement 'new()'. 2 | -------------------------------------------------------------------------------- /test/core/string/not.wren: -------------------------------------------------------------------------------- 1 | System.print(!"s") // expect: false 2 | System.print(!"") // expect: false 3 | -------------------------------------------------------------------------------- /test/core/string/replace_empty_old.wren: -------------------------------------------------------------------------------- 1 | "foo".replace("", "f") // expect runtime error: From must be a non-empty string. 2 | -------------------------------------------------------------------------------- /test/core/string/replace_new_not_string.wren: -------------------------------------------------------------------------------- 1 | "foo".replace("o", 1) // expect runtime error: To must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/replace_old_not_string.wren: -------------------------------------------------------------------------------- 1 | "foo".replace(1, "o") // expect runtime error: From must be a non-empty string. 2 | -------------------------------------------------------------------------------- /test/core/string/split_argument_not_string.wren: -------------------------------------------------------------------------------- 1 | "foo".split(1) // expect runtime error: Delimiter must be a non-empty string. 2 | -------------------------------------------------------------------------------- /test/core/string/split_empty_seperator.wren: -------------------------------------------------------------------------------- 1 | "foo".split("") // expect runtime error: Delimiter must be a non-empty string. 2 | -------------------------------------------------------------------------------- /test/core/string/starts_with_invalid_arg.wren: -------------------------------------------------------------------------------- 1 | System.print("abcd".startsWith(null)) // expect runtime error: Argument must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/subscript_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[1.5] // expect runtime error: Subscript must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_not_num.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a["2"] // expect runtime error: Subscript must be a number or a range. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_range_from_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = "string" 2 | a[1.5..2] // expect runtime error: Range start must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_range_from_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[3..2] // expect runtime error: Range start out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_range_from_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[-4..2] // expect runtime error: Range start out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_range_to_exclusive_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[1...4] // expect runtime error: Range end out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_range_to_exclusive_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[0...-5] // expect runtime error: Range end out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_range_to_not_int.wren: -------------------------------------------------------------------------------- 1 | var a = "string" 2 | a[1..2.5] // expect runtime error: Range end must be an integer. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_range_to_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[1..3] // expect runtime error: Range end out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_range_to_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[0..-4] // expect runtime error: Range end out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_too_large.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[4] // expect runtime error: Subscript out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/string/subscript_too_small.wren: -------------------------------------------------------------------------------- 1 | var a = "123" 2 | a[-5] // expect runtime error: Subscript out of bounds. 3 | -------------------------------------------------------------------------------- /test/core/string/to_string.wren: -------------------------------------------------------------------------------- 1 | System.print("".toString == "") // expect: true 2 | System.print("blah".toString == "blah") // expect: true 3 | 4 | // 8-bit clean. 5 | System.print("a\0b\0c".toString == "a\0b\0c") // expect: true 6 | System.print("a\0b\0c".toString == "a") // expect: false 7 | System.print("a\0b\0c".toString) // expect: a 8 | -------------------------------------------------------------------------------- /test/core/string/trim_chars_not_string.wren: -------------------------------------------------------------------------------- 1 | "abracadabra".trim(123) // expect runtime error: Characters must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/trim_end_chars_not_string.wren: -------------------------------------------------------------------------------- 1 | "abracadabra".trimEnd(123) // expect runtime error: Characters must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/trim_start_chars_not_string.wren: -------------------------------------------------------------------------------- 1 | "abracadabra".trimStart(123) // expect runtime error: Characters must be a string. 2 | -------------------------------------------------------------------------------- /test/core/string/type.wren: -------------------------------------------------------------------------------- 1 | System.print("s" is String) // expect: true 2 | System.print("s" is Object) // expect: true 3 | System.print("s" is Num) // expect: false 4 | System.print("s".type == String) // expect: true 5 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/iterate_not_int.wren: -------------------------------------------------------------------------------- 1 | "str".bytes.iterate(12.34) // expect runtime error: Iterator must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/iterate_wrong_type.wren: -------------------------------------------------------------------------------- 1 | "str".bytes.iterate("not num") // expect runtime error: Iterator must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/iterator_value_not_int.wren: -------------------------------------------------------------------------------- 1 | "abcd".bytes.iteratorValue(12.34) // expect runtime error: Index must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/iterator_value_not_num.wren: -------------------------------------------------------------------------------- 1 | "abcd".bytes.iteratorValue("not num") // expect runtime error: Index must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/iterator_value_too_large.wren: -------------------------------------------------------------------------------- 1 | "abcd".bytes.iteratorValue(4) // expect runtime error: Index out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/iterator_value_too_small.wren: -------------------------------------------------------------------------------- 1 | "abcd".bytes.iteratorValue(-5) // expect runtime error: Index out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/subscript_not_int.wren: -------------------------------------------------------------------------------- 1 | "abcd".bytes[12.34] // expect runtime error: Index must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/subscript_not_num.wren: -------------------------------------------------------------------------------- 1 | "abcd".bytes["not num"] // expect runtime error: Index must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/subscript_too_large.wren: -------------------------------------------------------------------------------- 1 | "abcd".bytes[4] // expect runtime error: Index out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string_byte_sequence/subscript_too_small.wren: -------------------------------------------------------------------------------- 1 | "abcd".bytes[-5] // expect runtime error: Index out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/iterate_iterator_not_int.wren: -------------------------------------------------------------------------------- 1 | "s".codePoints.iterate(1.5) // expect runtime error: Iterator must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/iterate_iterator_not_num.wren: -------------------------------------------------------------------------------- 1 | "s".codePoints.iterate("2") // expect runtime error: Iterator must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/iterator_value_not_int.wren: -------------------------------------------------------------------------------- 1 | System.print("string".codePoints.iteratorValue(12.34)) // expect runtime error: Index must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/iterator_value_not_num.wren: -------------------------------------------------------------------------------- 1 | System.print("string".codePoints.iteratorValue("not num")) // expect runtime error: Index must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/iterator_value_too_large.wren: -------------------------------------------------------------------------------- 1 | System.print("string".codePoints.iteratorValue(6)) // expect runtime error: Index out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/iterator_value_too_small.wren: -------------------------------------------------------------------------------- 1 | System.print("string".codePoints.iteratorValue(-7)) // expect runtime error: Index out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/subscript_incomplete.wren: -------------------------------------------------------------------------------- 1 | // The first byte of a two-octet sequence. 2 | System.print("\xc0".codePoints[0]) // expect: -1 3 | 4 | // The first byte of a three-octet sequence. 5 | System.print("\xe0".codePoints[0]) // expect: -1 6 | 7 | // The first two bytes of a three-octet sequence. 8 | System.print("\xe0\xae".codePoints[0]) // expect: -1 9 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/subscript_not_int.wren: -------------------------------------------------------------------------------- 1 | System.print("string".codePoints[12.34]) // expect runtime error: Index must be an integer. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/subscript_not_num.wren: -------------------------------------------------------------------------------- 1 | System.print("string".codePoints["not num"]) // expect runtime error: Index must be a number. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/subscript_too_large.wren: -------------------------------------------------------------------------------- 1 | System.print("string".codePoints[6]) // expect runtime error: Index out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/string_code_point_sequence/subscript_too_small.wren: -------------------------------------------------------------------------------- 1 | System.print("string".codePoints[-7]) // expect runtime error: Index out of bounds. 2 | -------------------------------------------------------------------------------- /test/core/system/print.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | 4 | toString { "Foo.toString" } 5 | } 6 | 7 | // Calls toString on argument. 8 | System.print(Foo.new()) // expect: Foo.toString 9 | 10 | // Returns the argument. 11 | System.print(System.print(1) == 1) // expect: 1 12 | // expect: true 13 | -------------------------------------------------------------------------------- /test/core/system/print_all.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | 4 | toString { "Foo" } 5 | } 6 | 7 | System.printAll([]) // expect: 8 | System.printAll([1, true, Foo.new(), "s"]) // expect: 1trueFoos 9 | -------------------------------------------------------------------------------- /test/core/system/print_all_not_sequence.wren: -------------------------------------------------------------------------------- 1 | System.printAll(123) // expect runtime error: Num does not implement 'iterate(_)'. 2 | -------------------------------------------------------------------------------- /test/core/system/print_bad_to_string.wren: -------------------------------------------------------------------------------- 1 | class BadToString { 2 | construct new() {} 3 | toString { 3 } 4 | } 5 | 6 | System.print(BadToString.new()) // expect: [invalid toString] 7 | -------------------------------------------------------------------------------- /test/core/system/write_all.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | 4 | toString { "Foo" } 5 | } 6 | 7 | System.writeAll([]) // expect: 8 | System.print() 9 | System.writeAll([1, true, Foo.new(), "s"]) // expect: 1trueFoos 10 | System.print() 11 | -------------------------------------------------------------------------------- /test/core/system/write_all_not_sequence.wren: -------------------------------------------------------------------------------- 1 | System.writeAll(123) // expect runtime error: Num does not implement 'iterate(_)'. 2 | -------------------------------------------------------------------------------- /test/core/system/write_bad_to_string.wren: -------------------------------------------------------------------------------- 1 | class BadToString { 2 | construct new() {} 3 | toString { 3 } 4 | } 5 | 6 | System.write(BadToString.new()) 7 | System.print("!") // expect: [invalid toString]! 8 | -------------------------------------------------------------------------------- /test/language/assignment/associativity.wren: -------------------------------------------------------------------------------- 1 | var a = "a" 2 | var b = "b" 3 | var c = "c" 4 | 5 | // Assignment is right-associative. 6 | a = b = c 7 | System.print(a) // expect: c 8 | System.print(b) // expect: c 9 | System.print(c) // expect: c 10 | -------------------------------------------------------------------------------- /test/language/assignment/global.wren: -------------------------------------------------------------------------------- 1 | var a = "before" 2 | System.print(a) // expect: before 3 | 4 | a = "after" 5 | System.print(a) // expect: after 6 | 7 | System.print(a = "arg") // expect: arg 8 | System.print(a) // expect: arg 9 | -------------------------------------------------------------------------------- /test/language/assignment/grouping.wren: -------------------------------------------------------------------------------- 1 | var a = "a" 2 | (a) = "value" // expect error 3 | -------------------------------------------------------------------------------- /test/language/assignment/infix_operator.wren: -------------------------------------------------------------------------------- 1 | var a = "a" 2 | var b = "b" 3 | a + b = "value" // expect error 4 | -------------------------------------------------------------------------------- /test/language/assignment/is.wren: -------------------------------------------------------------------------------- 1 | var a = "a" 2 | var b = "b" 3 | b is a = "value" // expect error 4 | -------------------------------------------------------------------------------- /test/language/assignment/local.wren: -------------------------------------------------------------------------------- 1 | Fn.new { 2 | var a = "before" 3 | System.print(a) // expect: before 4 | 5 | a = "after" 6 | System.print(a) // expect: after 7 | 8 | System.print(a = "arg") // expect: arg 9 | System.print(a) // expect: arg 10 | }.call() 11 | -------------------------------------------------------------------------------- /test/language/assignment/prefix_operator.wren: -------------------------------------------------------------------------------- 1 | var a = "a" 2 | !a = "value" // expect error 3 | -------------------------------------------------------------------------------- /test/language/assignment/syntax.wren: -------------------------------------------------------------------------------- 1 | // Chained assignment. 2 | var a = "a" 3 | var b = "b" 4 | a = b = "chain" 5 | System.print(a) // expect: chain 6 | System.print(b) // expect: chain 7 | 8 | // Assignment on RHS of variable. 9 | var c = a = "var" 10 | System.print(a) // expect: var 11 | System.print(c) // expect: var 12 | -------------------------------------------------------------------------------- /test/language/assignment/undefined.wren: -------------------------------------------------------------------------------- 1 | unknown = "what" // expect error 2 | -------------------------------------------------------------------------------- /test/language/bom.wren: -------------------------------------------------------------------------------- 1 | // This file should have a UTF-8 byte order mark 2 | System.print("ok") // expect: ok 3 | -------------------------------------------------------------------------------- /test/language/break/closure_in_for.wren: -------------------------------------------------------------------------------- 1 | var f 2 | for (i in [1, 2, 3]) { 3 | var j = 4 4 | f = Fn.new { System.print(i + j) } 5 | break 6 | } 7 | 8 | f.call() 9 | // expect: 5 10 | -------------------------------------------------------------------------------- /test/language/break/closure_in_while.wren: -------------------------------------------------------------------------------- 1 | var f 2 | while (true) { 3 | var i = "i" 4 | f = Fn.new { System.print(i) } 5 | break 6 | } 7 | 8 | f.call() 9 | // expect: i 10 | -------------------------------------------------------------------------------- /test/language/break/exit_local_scopes.wren: -------------------------------------------------------------------------------- 1 | for (i in 0..10) { 2 | System.print(i) 3 | 4 | { 5 | var a = "a" 6 | { 7 | var b = "b" 8 | { 9 | var c = "c" 10 | if (i > 1) break 11 | } 12 | } 13 | } 14 | } 15 | 16 | // expect: 0 17 | // expect: 1 18 | // expect: 2 19 | -------------------------------------------------------------------------------- /test/language/break/in_for_loop.wren: -------------------------------------------------------------------------------- 1 | for (i in [1, 2, 3, 4, 5]) { 2 | System.print(i) 3 | if (i > 2) break 4 | System.print(i) 5 | } 6 | // expect: 1 7 | // expect: 1 8 | // expect: 2 9 | // expect: 2 10 | // expect: 3 11 | -------------------------------------------------------------------------------- /test/language/break/in_function_in_loop.wren: -------------------------------------------------------------------------------- 1 | var done = false 2 | while (!done) { 3 | Fn.new { 4 | break // expect error 5 | } 6 | done = true 7 | } -------------------------------------------------------------------------------- /test/language/break/in_method_in_loop.wren: -------------------------------------------------------------------------------- 1 | var done = false 2 | while (!done) { 3 | class Foo { 4 | method { 5 | break // expect error 6 | } 7 | } 8 | done = true 9 | } 10 | -------------------------------------------------------------------------------- /test/language/break/in_while_loop.wren: -------------------------------------------------------------------------------- 1 | var i = 0 2 | while (true) { 3 | i = i + 1 4 | System.print(i) 5 | if (i > 2) break 6 | System.print(i) 7 | } 8 | // expect: 1 9 | // expect: 1 10 | // expect: 2 11 | // expect: 2 12 | // expect: 3 13 | -------------------------------------------------------------------------------- /test/language/break/outside_loop.wren: -------------------------------------------------------------------------------- 1 | break // expect error 2 | -------------------------------------------------------------------------------- /test/language/class/attributes/compile_only.wren: -------------------------------------------------------------------------------- 1 | // Attributes without a ! shouldn't be 2 | // passed to the runtime, they're compiled out 3 | 4 | #compileonly 5 | class WithNonRuntime { 6 | #unused 7 | method() {} 8 | } 9 | System.print(WithNonRuntime.attributes == null) // expect: true 10 | -------------------------------------------------------------------------------- /test/language/class/attributes/invalid_expression.wren: -------------------------------------------------------------------------------- 1 | 2 | // When used in an expression location, 3 | // the error remains Error at '#': Expected expression 4 | 5 | #valid 6 | class Example { 7 | 8 | #valid 9 | method() { 10 | return #invalid 1 // expect error 11 | } 12 | } -------------------------------------------------------------------------------- /test/language/class/attributes/invalid_scope.wren: -------------------------------------------------------------------------------- 1 | 2 | 3 | #valid 4 | class Example { 5 | 6 | #valid 7 | method() { 8 | #invalid // expect error 9 | var a = 3 10 | } 11 | } -------------------------------------------------------------------------------- /test/language/class/attributes/invalid_toplevel.wren: -------------------------------------------------------------------------------- 1 | 2 | 3 | #meta // expect error 4 | var A = 3 -------------------------------------------------------------------------------- /test/language/class/attributes/without.wren: -------------------------------------------------------------------------------- 1 | // With no attributes defined, no ClassAttributes should be allocated 2 | 3 | class Without {} 4 | System.print(Without.attributes == null) // expect: true 5 | -------------------------------------------------------------------------------- /test/language/class/field_in_foreign_class.wren: -------------------------------------------------------------------------------- 1 | foreign class Foo { 2 | bar { 3 | // Can't read a field. 4 | System.print(_bar) // expect error 5 | 6 | // Or write one. 7 | _bar = "value" // expect error 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/language/class/foreign_class_inherit_fields.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | method() { 3 | _field = "value" 4 | } 5 | } 6 | 7 | foreign class Bar is Foo {} // expect runtime error: Foreign class 'Bar' may not inherit from a class with fields. 8 | -------------------------------------------------------------------------------- /test/language/class/missing_class_after_foreign.wren: -------------------------------------------------------------------------------- 1 | // Missing "class". 2 | foreign blah A {} // expect error 3 | -------------------------------------------------------------------------------- /test/language/class/name_inside_body.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | 4 | static sayName { 5 | System.print(Foo) 6 | } 7 | 8 | sayName { 9 | System.print(Foo) 10 | } 11 | 12 | static toString { "Foo!" } 13 | } 14 | 15 | Foo.sayName // expect: Foo! 16 | Foo.new().sayName // expect: Foo! 17 | -------------------------------------------------------------------------------- /test/language/class/newline_after_class.wren: -------------------------------------------------------------------------------- 1 | class // expect error 2 | Foo {} -------------------------------------------------------------------------------- /test/language/class/newline_after_static.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static // expect error 3 | method {} // expect error 4 | } 5 | 6 | // The second error is cascaded. -------------------------------------------------------------------------------- /test/language/class/syntax.wren: -------------------------------------------------------------------------------- 1 | // Empty body. 2 | class A {} 3 | 4 | // Newline body. 5 | class B { 6 | 7 | } 8 | 9 | // No newline after last method. 10 | class C { 11 | method {} } 12 | -------------------------------------------------------------------------------- /test/language/closure/close_over_function_parameter.wren: -------------------------------------------------------------------------------- 1 | var f = null 2 | 3 | Fn.new {|param| 4 | f = Fn.new { 5 | System.print(param) 6 | } 7 | }.call("param") 8 | 9 | f.call() // expect: param 10 | -------------------------------------------------------------------------------- /test/language/closure/close_over_method_parameter.wren: -------------------------------------------------------------------------------- 1 | var F = null 2 | 3 | class Foo { 4 | construct new() {} 5 | 6 | method(param) { 7 | F = Fn.new { 8 | System.print(param) 9 | } 10 | } 11 | } 12 | 13 | Foo.new().method("param") 14 | F.call() // expect: param 15 | -------------------------------------------------------------------------------- /test/language/closure/closed_closure_in_function.wren: -------------------------------------------------------------------------------- 1 | var f = null 2 | 3 | { 4 | var local = "local" 5 | f = Fn.new { 6 | System.print(local) 7 | } 8 | } 9 | 10 | f.call() // expect: local 11 | -------------------------------------------------------------------------------- /test/language/closure/open_closure_in_function.wren: -------------------------------------------------------------------------------- 1 | { 2 | var local = "local" 3 | Fn.new { 4 | System.print(local) // expect: local 5 | }.call() 6 | } 7 | -------------------------------------------------------------------------------- /test/language/closure/reference_closure_multiple_times.wren: -------------------------------------------------------------------------------- 1 | var f = null 2 | 3 | { 4 | var a = "a" 5 | f = Fn.new { 6 | System.print(a) 7 | System.print(a) 8 | } 9 | } 10 | 11 | f.call() 12 | // expect: a 13 | // expect: a 14 | -------------------------------------------------------------------------------- /test/language/closure/shadow_closure_with_local.wren: -------------------------------------------------------------------------------- 1 | { 2 | var foo = "closure" 3 | Fn.new { 4 | { 5 | System.print(foo) // expect: closure 6 | var foo = "shadow" 7 | System.print(foo) // expect: shadow 8 | } 9 | System.print(foo) // expect: closure 10 | }.call() 11 | } 12 | -------------------------------------------------------------------------------- /test/language/comments/block.wren: -------------------------------------------------------------------------------- 1 | // In middle of line. 2 | System.print/* ... */(/* */"ok"/* */) // expect: ok 3 | 4 | // Nested. 5 | System.print(/* in /* nest */ out */"ok") // expect: ok 6 | -------------------------------------------------------------------------------- /test/language/comments/block_at_eof.wren: -------------------------------------------------------------------------------- 1 | System.print("ok") // expect: ok 2 | /* comment */ -------------------------------------------------------------------------------- /test/language/comments/line_at_eof.wren: -------------------------------------------------------------------------------- 1 | System.print("ok") // expect: ok 2 | // comment -------------------------------------------------------------------------------- /test/language/comments/only_line_comment.wren: -------------------------------------------------------------------------------- 1 | // comment -------------------------------------------------------------------------------- /test/language/comments/only_line_comment_and_line.wren: -------------------------------------------------------------------------------- 1 | // comment 2 | -------------------------------------------------------------------------------- /test/language/comments/unicode.wren: -------------------------------------------------------------------------------- 1 | // Unicode characters are allowed in comments. 2 | // 3 | // Latin 1 Supplement: £§¶ÜÞ 4 | // Latin Extended-A: ĐĦŋœ 5 | // Latin Extended-B: ƂƢƩǁ 6 | // Other stuff: ឃᢆ᯽₪ℜ↩⊗┺░ 7 | // Emoji: ☃☺♣ 8 | 9 | // TODO: What about combining characters? 10 | 11 | System.print("ok") // expect: ok 12 | -------------------------------------------------------------------------------- /test/language/comments/unterminated_block.wren: -------------------------------------------------------------------------------- 1 | // expect error line 3 2 | System.print("nope") /* 3 | oops -------------------------------------------------------------------------------- /test/language/comments/unterminated_nested_block.wren: -------------------------------------------------------------------------------- 1 | // expect error line 4 2 | System.print("nope") /* /* /* 3 | */ 4 | oops -------------------------------------------------------------------------------- /test/language/conditional/conditional_in_then.wren: -------------------------------------------------------------------------------- 1 | 1 ? 2 ? 3 : 4 : 5 // expect error 2 | -------------------------------------------------------------------------------- /test/language/conditional/missing_colon.wren: -------------------------------------------------------------------------------- 1 | true ? 1 // expect error 2 | "next expression" -------------------------------------------------------------------------------- /test/language/conditional/missing_condition.wren: -------------------------------------------------------------------------------- 1 | ? 1 : 2 // expect error 2 | -------------------------------------------------------------------------------- /test/language/conditional/missing_else.wren: -------------------------------------------------------------------------------- 1 | (true ? 1 :) // expect error 2 | -------------------------------------------------------------------------------- /test/language/conditional/missing_question.wren: -------------------------------------------------------------------------------- 1 | true 1 : 2 // expect error 2 | -------------------------------------------------------------------------------- /test/language/conditional/missing_then.wren: -------------------------------------------------------------------------------- 1 | (true ? : 2) // expect error 2 | -------------------------------------------------------------------------------- /test/language/conditional/newlines.wren: -------------------------------------------------------------------------------- 1 | // Newline after '?'. 2 | System.print(true ? 3 | "yes" : "no") // expect: yes 4 | 5 | // Newline after ':'. 6 | System.print(false ? "yes" : 7 | "no") // expect: no 8 | -------------------------------------------------------------------------------- /test/language/conditional/short_circuit.wren: -------------------------------------------------------------------------------- 1 | true ? System.print("ok") : System.print("no") // expect: ok 2 | false ? System.print("no") : System.print("ok") // expect: ok 3 | -------------------------------------------------------------------------------- /test/language/constructor/cannot_be_infix.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct +(value) { // expect error 3 | System.print("ok") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/constructor/cannot_be_minus.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct -(value) { // expect error 3 | System.print("ok") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/constructor/cannot_be_setter.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct name=(value) { // expect error 3 | System.print("ok") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/constructor/cannot_be_static.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static construct new() {} // expect error 3 | construct static new() {} // expect error 4 | } 5 | -------------------------------------------------------------------------------- /test/language/constructor/cannot_be_subscript.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct [value] { // expect error 3 | System.print("ok") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/constructor/cannot_be_unary.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct ! { // expect error 3 | System.print("ok") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/constructor/cannot_call_initializer.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() { 3 | System.print("ok") 4 | } 5 | } 6 | 7 | var foo = Foo.new() // expect: ok 8 | foo.new() // expect runtime error: Foo does not implement 'new()'. 9 | -------------------------------------------------------------------------------- /test/language/constructor/cannot_return_value.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() { 3 | return 1 // expect error 4 | } 5 | } -------------------------------------------------------------------------------- /test/language/constructor/no_default.wren: -------------------------------------------------------------------------------- 1 | class Foo {} 2 | 3 | // Classes do not get a constructor by default. 4 | var foo = Foo.new() // expect runtime error: Foo metaclass does not implement 'new()'. 5 | -------------------------------------------------------------------------------- /test/language/constructor/no_parameter_list.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new { // expect error 3 | System.print("ok") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/constructor/not_inherited.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct base() {} 3 | } 4 | 5 | class Bar is Foo {} 6 | 7 | Bar.base() // expect runtime error: Bar metaclass does not implement 'base()'. 8 | -------------------------------------------------------------------------------- /test/language/constructor/super_must_have_args.wren: -------------------------------------------------------------------------------- 1 | class A {} 2 | 3 | class B is A { 4 | construct new() { 5 | super // expect error 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/language/continue/closure_in_for.wren: -------------------------------------------------------------------------------- 1 | var f 2 | for (i in [1, 2, 3]) { 3 | var j = 4 4 | f = Fn.new { System.print(i + j) } 5 | continue 6 | } 7 | 8 | f.call() 9 | // expect: 7 -------------------------------------------------------------------------------- /test/language/continue/closure_in_while.wren: -------------------------------------------------------------------------------- 1 | var f 2 | while (f == null) { 3 | var i = "i" 4 | f = Fn.new { System.print(i) } 5 | continue 6 | } 7 | 8 | f.call() 9 | // expect: i 10 | -------------------------------------------------------------------------------- /test/language/continue/exit_local_scopes.wren: -------------------------------------------------------------------------------- 1 | for (i in 0..5) { 2 | { 3 | var a = "a" 4 | { 5 | var b = "b" 6 | { 7 | var c = "c" 8 | if (i == 1) continue 9 | } 10 | } 11 | } 12 | 13 | System.print(i) 14 | } 15 | 16 | // expect: 0 17 | // expect: 2 18 | // expect: 3 19 | // expect: 4 20 | // expect: 5 21 | -------------------------------------------------------------------------------- /test/language/continue/in_for_loop.wren: -------------------------------------------------------------------------------- 1 | for (i in [1, 2, 3, 4, 5]) { 2 | System.print(i) 3 | if (i > 2) continue 4 | System.print(i) 5 | } 6 | // expect: 1 7 | // expect: 1 8 | // expect: 2 9 | // expect: 2 10 | // expect: 3 11 | // expect: 4 12 | // expect: 5 13 | -------------------------------------------------------------------------------- /test/language/continue/in_function_in_loop.wren: -------------------------------------------------------------------------------- 1 | var done = false 2 | while (!done) { 3 | Fn.new { 4 | continue // expect error 5 | } 6 | done = true 7 | } -------------------------------------------------------------------------------- /test/language/continue/in_method_in_loop.wren: -------------------------------------------------------------------------------- 1 | var done = false 2 | while (!done) { 3 | class Foo { 4 | method { 5 | continue // expect error 6 | } 7 | } 8 | done = true 9 | } 10 | -------------------------------------------------------------------------------- /test/language/continue/in_while_loop.wren: -------------------------------------------------------------------------------- 1 | var i = 0 2 | while (true) { 3 | i = i + 1 4 | System.print(i) 5 | if (i <= 2) continue 6 | System.print(i) 7 | break 8 | } 9 | // expect: 1 10 | // expect: 2 11 | // expect: 3 12 | // expect: 3 13 | -------------------------------------------------------------------------------- /test/language/continue/outside_loop.wren: -------------------------------------------------------------------------------- 1 | continue // expect error 2 | -------------------------------------------------------------------------------- /test/language/deeply_nested_gc.wren: -------------------------------------------------------------------------------- 1 | var head 2 | 3 | for (i in 1..400000) { 4 | head = { "next" : head } 5 | } 6 | 7 | System.gc() 8 | System.print("done") // expect: done 9 | -------------------------------------------------------------------------------- /test/language/empty_block.wren: -------------------------------------------------------------------------------- 1 | {} // By itself. 2 | 3 | // In a statement. 4 | if (true) {} 5 | if (false) {} else {} 6 | 7 | System.print("ok") // expect: ok -------------------------------------------------------------------------------- /test/language/empty_file.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/language/empty_file.wren -------------------------------------------------------------------------------- /test/language/field/default_to_null.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | write { System.print(_field) } 4 | } 5 | 6 | Foo.new().write // expect: null 7 | -------------------------------------------------------------------------------- /test/language/field/in_fn_in_static_method.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static bar { 3 | Fn.new { _field = "wat" } // expect error 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/field/in_static_method.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static bar { 3 | _field = "wat" // expect error 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/field/outside_class.wren: -------------------------------------------------------------------------------- 1 | _field = "wat" // expect error 2 | -------------------------------------------------------------------------------- /test/language/field/use_before_set.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | write { System.print(_field) } // Compile a use of the field... 4 | init { _field = "value" } // ...before an assignment to it. 5 | } 6 | 7 | var foo = Foo.new() 8 | // But invoke them in the right order. 9 | foo.init 10 | foo.write // expect: value 11 | -------------------------------------------------------------------------------- /test/language/for/close_over_loop_variable.wren: -------------------------------------------------------------------------------- 1 | var list = [] 2 | 3 | for (i in [1, 2, 3]) { 4 | list.add(Fn.new { System.print(i) }) 5 | } 6 | 7 | for (f in list) f.call() 8 | // expect: 1 9 | // expect: 2 10 | // expect: 3 11 | -------------------------------------------------------------------------------- /test/language/for/closure_in_body.wren: -------------------------------------------------------------------------------- 1 | var list = [] 2 | 3 | for (i in [1, 2, 3]) { 4 | var j = i + 1 5 | list.add(Fn.new { System.print(j) }) 6 | } 7 | 8 | for (f in list) f.call() 9 | // expect: 2 10 | // expect: 3 11 | // expect: 4 12 | -------------------------------------------------------------------------------- /test/language/for/newline_after_for.wren: -------------------------------------------------------------------------------- 1 | for // expect error 2 | (i in [1, 2, 3]) System.print(i) 3 | -------------------------------------------------------------------------------- /test/language/for/newline_before_in.wren: -------------------------------------------------------------------------------- 1 | for (i // expect error 2 | in [1]) System.print(i) 3 | -------------------------------------------------------------------------------- /test/language/for/only_evaluate_sequence_once.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | System.print("evaluate sequence") 3 | return [1, 2, 3] 4 | } 5 | 6 | for (i in f.call()) System.print(i) 7 | // expect: evaluate sequence 8 | // expect: 1 9 | // expect: 2 10 | // expect: 3 11 | -------------------------------------------------------------------------------- /test/language/for/return_closure.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | for (i in [1, 2, 3]) { 3 | return Fn.new { System.print(i) } 4 | } 5 | } 6 | 7 | var g = f.call() 8 | g.call() 9 | // expect: 1 10 | -------------------------------------------------------------------------------- /test/language/for/return_inside.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | for (i in [1, 2, 3]) { 3 | return i 4 | } 5 | } 6 | 7 | System.print(f.call()) 8 | // expect: 1 9 | -------------------------------------------------------------------------------- /test/language/for/syntax.wren: -------------------------------------------------------------------------------- 1 | // Single-expression body. 2 | for (i in [1]) System.print(i) 3 | // expect: 1 4 | 5 | // Block body. 6 | for (i in [1]) { 7 | System.print(i) 8 | } 9 | // expect: 1 10 | 11 | // Newline after "in". 12 | for (i in 13 | [1]) System.print(i) 14 | // expect: 1 -------------------------------------------------------------------------------- /test/language/foreign/foreign_after_static.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static foreign method // expect error 3 | } 4 | -------------------------------------------------------------------------------- /test/language/foreign/foreign_method_with_body.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | foreign method { "body" } // expect error 3 | } 4 | -------------------------------------------------------------------------------- /test/language/foreign/unknown_method.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | foreign someUnknownMethod // expect runtime error: Could not find foreign method 'someUnknownMethod' for class Foo in module './test/language/foreign/unknown_method'. 3 | } 4 | -------------------------------------------------------------------------------- /test/language/function/empty_body.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new {} 2 | System.print(f.call()) // expect: null 3 | -------------------------------------------------------------------------------- /test/language/function/newline_body.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | // Hi. 3 | } 4 | System.print(f.call()) // expect: null 5 | -------------------------------------------------------------------------------- /test/language/function/newline_in_expression_block.wren: -------------------------------------------------------------------------------- 1 | Fn.new { System.print("ok") // expect error 2 | }.call() 3 | -------------------------------------------------------------------------------- /test/language/function/no_newline_before_close.wren: -------------------------------------------------------------------------------- 1 | Fn.new { 2 | System.print("ok") } // expect error -------------------------------------------------------------------------------- /test/language/function/no_parameters.wren: -------------------------------------------------------------------------------- 1 | Fn.new {|| null } // expect error 2 | -------------------------------------------------------------------------------- /test/language/if/dangling_else.wren: -------------------------------------------------------------------------------- 1 | // A dangling else binds to the right-most if. 2 | if (true) if (false) System.print("bad") else System.print("good") // expect: good 3 | if (false) if (true) System.print("bad") else System.print("bad") 4 | -------------------------------------------------------------------------------- /test/language/if/else.wren: -------------------------------------------------------------------------------- 1 | // Evaluate the 'else' expression if the condition is false. 2 | if (true) System.print("good") else System.print("bad") // expect: good 3 | if (false) System.print("bad") else System.print("good") // expect: good 4 | 5 | // Allow block body. 6 | if (false) null else { System.print("block") } // expect: block 7 | -------------------------------------------------------------------------------- /test/language/if/if.wren: -------------------------------------------------------------------------------- 1 | // Evaluate the 'then' expression if the condition is true. 2 | if (true) System.print("good") // expect: good 3 | if (false) System.print("bad") 4 | 5 | // Allow block body. 6 | if (true) { System.print("block") } // expect: block 7 | 8 | // Assignment in if condition. 9 | var a = false 10 | if (a = true) System.print(a) // expect: true 11 | -------------------------------------------------------------------------------- /test/language/if/newline_after_else.wren: -------------------------------------------------------------------------------- 1 | if (true) "ok" else // expect error 2 | -------------------------------------------------------------------------------- /test/language/if/newline_after_if.wren: -------------------------------------------------------------------------------- 1 | if // expect error 2 | (true) System.print("bad") 3 | -------------------------------------------------------------------------------- /test/language/ignore_carriage_returns.wren: -------------------------------------------------------------------------------- 1 | // Sprinkle some carriage returns to ensure they are ignored anywhere: 2 | System .print("one" ) 3 | System.print ("two") 4 | 5 | // Generate a compile error so we can test that the line number is correct. 6 | + * // expect error 7 | -------------------------------------------------------------------------------- /test/language/inheritance/do_not_inherit_static_methods.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static methodOnFoo { System.print("foo") } 3 | } 4 | 5 | class Bar is Foo {} 6 | 7 | Bar.methodOnFoo // expect runtime error: Bar metaclass does not implement 'methodOnFoo'. 8 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_bool.wren: -------------------------------------------------------------------------------- 1 | class Subclass is Bool {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Bool'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_class.wren: -------------------------------------------------------------------------------- 1 | class Subclass is Class {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Class'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_closure.wren: -------------------------------------------------------------------------------- 1 | var ClosureType 2 | 3 | { 4 | var a = "a" 5 | ClosureType = Fn.new { System.print(a) }.type 6 | } 7 | 8 | class Subclass is ClosureType {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Fn'. 9 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_fiber.wren: -------------------------------------------------------------------------------- 1 | class Subclass is Fiber {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Fiber'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_fn.wren: -------------------------------------------------------------------------------- 1 | class Subclass is Fn {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Fn'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_list.wren: -------------------------------------------------------------------------------- 1 | class Subclass is List {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'List'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_map.wren: -------------------------------------------------------------------------------- 1 | class Subclass is Map {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Map'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_nonclass.wren: -------------------------------------------------------------------------------- 1 | class Foo is 123 {} // expect runtime error: Class 'Foo' cannot inherit from a non-class object. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_null.wren: -------------------------------------------------------------------------------- 1 | class Foo is null {} // expect runtime error: Class 'Foo' cannot inherit from a non-class object. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_null_class.wren: -------------------------------------------------------------------------------- 1 | class Subclass is Null {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Null'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_num.wren: -------------------------------------------------------------------------------- 1 | class Subclass is Num {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Num'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_range.wren: -------------------------------------------------------------------------------- 1 | class Subclass is Range {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Range'. 2 | -------------------------------------------------------------------------------- /test/language/inheritance/inherit_from_string.wren: -------------------------------------------------------------------------------- 1 | class Subclass is String {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'String'. 2 | -------------------------------------------------------------------------------- /test/language/interpolation/empty.wren: -------------------------------------------------------------------------------- 1 | // expect error line 3 2 | " %() " 3 | -------------------------------------------------------------------------------- /test/language/interpolation/runtime_error_in_expression.wren: -------------------------------------------------------------------------------- 1 | System.print("%(123.badMethod)") // expect runtime error: Num does not implement 'badMethod'. 2 | -------------------------------------------------------------------------------- /test/language/interpolation/switch_fiber.wren: -------------------------------------------------------------------------------- 1 | var fiber = Fiber.new { 2 | System.print("in fiber") 3 | Fiber.yield("result") 4 | } 5 | 6 | System.print("outer %(fiber.call()) string") 7 | // expect: in fiber 8 | // expect: outer result string 9 | -------------------------------------------------------------------------------- /test/language/interpolation/unterminated.wren: -------------------------------------------------------------------------------- 1 | " %( 2 | // expect error -------------------------------------------------------------------------------- /test/language/interpolation/unterminated_expression.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | " %(123" -------------------------------------------------------------------------------- /test/language/list/duplicate_comma.wren: -------------------------------------------------------------------------------- 1 | [1,,2] // expect error 2 | -------------------------------------------------------------------------------- /test/language/list/duplicate_trailing_comma.wren: -------------------------------------------------------------------------------- 1 | [1,,] // expect error 2 | -------------------------------------------------------------------------------- /test/language/list/empty_list_with_comma.wren: -------------------------------------------------------------------------------- 1 | [,] // expect error 2 | -------------------------------------------------------------------------------- /test/language/list/eof_after_comma.wren: -------------------------------------------------------------------------------- 1 | [1, 2, 2 | // expect error -------------------------------------------------------------------------------- /test/language/list/eof_after_element.wren: -------------------------------------------------------------------------------- 1 | [1, 2 2 | // expect error -------------------------------------------------------------------------------- /test/language/list/grow_shrink.wren: -------------------------------------------------------------------------------- 1 | // This mostly tests that lists handle growing and shrinking their memory. 2 | var list = [] 3 | for (i in 0..200) { 4 | list.add(i) 5 | } 6 | 7 | for (i in 0..195) { 8 | list.removeAt(-1) 9 | } 10 | 11 | System.print(list) // expect: [0, 1, 2, 3, 4] 12 | -------------------------------------------------------------------------------- /test/language/list/newline_before_comma.wren: -------------------------------------------------------------------------------- 1 | var list = ["a" 2 | , "b"] // expect error 3 | -------------------------------------------------------------------------------- /test/language/list/trailing_comma.wren: -------------------------------------------------------------------------------- 1 | var list = ["a", "b",] 2 | 3 | System.print(list[0]) // expect: a 4 | System.print(list[1]) // expect: b 5 | -------------------------------------------------------------------------------- /test/language/logical_operator/and_truth.wren: -------------------------------------------------------------------------------- 1 | // False and null are false. 2 | System.print(false && "bad") // expect: false 3 | System.print(null && "bad") // expect: null 4 | 5 | // Everything else is true. 6 | System.print(true && "ok") // expect: ok 7 | System.print(0 && "ok") // expect: ok 8 | System.print("" && "ok") // expect: ok 9 | -------------------------------------------------------------------------------- /test/language/logical_operator/or_truth.wren: -------------------------------------------------------------------------------- 1 | // False and null are false. 2 | System.print(false || "ok") // expect: ok 3 | System.print(null || "ok") // expect: ok 4 | 5 | // Everything else is true. 6 | System.print(true || "ok") // expect: true 7 | System.print(0 || "ok") // expect: 0 8 | System.print("s" || "ok") // expect: s 9 | -------------------------------------------------------------------------------- /test/language/map/bad_key_precedence.wren: -------------------------------------------------------------------------------- 1 | var map = { 2 | 1 + 2: "bad key" // expect error 3 | } 4 | -------------------------------------------------------------------------------- /test/language/map/duplicate_comma.wren: -------------------------------------------------------------------------------- 1 | {1:1,,2:2} // expect error 2 | -------------------------------------------------------------------------------- /test/language/map/duplicate_trailing_comma.wren: -------------------------------------------------------------------------------- 1 | {1:1,,} // expect error 2 | -------------------------------------------------------------------------------- /test/language/map/empty_map_with_comma.wren: -------------------------------------------------------------------------------- 1 | {,} // expect error 2 | -------------------------------------------------------------------------------- /test/language/map/eof_after_colon.wren: -------------------------------------------------------------------------------- 1 | var map = {1: // expect error -------------------------------------------------------------------------------- /test/language/map/eof_after_comma.wren: -------------------------------------------------------------------------------- 1 | var map = {1: 2, 2 | // expect error -------------------------------------------------------------------------------- /test/language/map/eof_after_key.wren: -------------------------------------------------------------------------------- 1 | var map = {1 // expect error -------------------------------------------------------------------------------- /test/language/map/eof_after_value.wren: -------------------------------------------------------------------------------- 1 | var map = {1: 2 2 | // expect error -------------------------------------------------------------------------------- /test/language/map/trailing_comma.wren: -------------------------------------------------------------------------------- 1 | var map = { 2 | "a": 1, 3 | "b": 2, 4 | } 5 | 6 | System.print(map["a"]) // expect: 1 7 | System.print(map["b"]) // expect: 2 8 | -------------------------------------------------------------------------------- /test/language/method/call_name_too_long.wren: -------------------------------------------------------------------------------- 1 | // Don't want to actually execute it. 2 | if (false) { 3 | 0.thisIsAMethodNameThatExceedsTheMaximumNameLengthOf64CharactersBy1 // expect error 4 | } 5 | -------------------------------------------------------------------------------- /test/language/method/duplicate_methods.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | foo() {} 4 | foo() {} // expect error 5 | 6 | static bar() {} 7 | static bar() {} // expect error 8 | 9 | // No error on instance and static method with same signature. 10 | baz() {} 11 | static baz() {} 12 | } 13 | -------------------------------------------------------------------------------- /test/language/method/empty_block.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | bar {} 4 | } 5 | 6 | System.print(Foo.new().bar) // expect: null 7 | -------------------------------------------------------------------------------- /test/language/method/empty_subscript_call.wren: -------------------------------------------------------------------------------- 1 | var list = [1, 2] 2 | list[] // expect error 3 | "don't actually want error here, but cascades from above" // expect error -------------------------------------------------------------------------------- /test/language/method/empty_subscript_definition.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | [] { "empty" } // expect error 3 | } 4 | -------------------------------------------------------------------------------- /test/language/method/long_name.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum { 4 | return "result" 5 | } 6 | } 7 | 8 | System.print(Foo.new().thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result 9 | -------------------------------------------------------------------------------- /test/language/method/name_too_long.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | thisIsAMethodNameThatExceedsTheMaximumNameLengthOf64CharactersBy1 { // expect error 3 | "body" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/method/no_parameters_new_line.wren: -------------------------------------------------------------------------------- 1 | 2 | class Foo { 3 | static call( 4 | ) { 5 | System.print("Success") // expect: Success 6 | } 7 | 8 | construct new () {} 9 | 10 | call( 11 | ) { 12 | System.print("Success") // expect: Success 13 | } 14 | } 15 | 16 | Foo.call( 17 | ) 18 | Foo.new().call( 19 | ) 20 | -------------------------------------------------------------------------------- /test/language/method/not_found.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | } 4 | 5 | Foo.new().someUnknownMethod // expect runtime error: Foo does not implement 'someUnknownMethod'. 6 | -------------------------------------------------------------------------------- /test/language/method/not_found_eleven_arguments.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | } 4 | 5 | Foo.new().someUnknownMethod(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) // expect runtime error: Foo does not implement 'someUnknownMethod(_,_,_,_,_,_,_,_,_,_,_)'. -------------------------------------------------------------------------------- /test/language/method/not_found_multiple_arguments.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | } 4 | 5 | Foo.new().someUnknownMethod(1, 2) // expect runtime error: Foo does not implement 'someUnknownMethod(_,_)'. -------------------------------------------------------------------------------- /test/language/method/not_found_one_argument.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | } 4 | 5 | Foo.new().someUnknownMethod(1) // expect runtime error: Foo does not implement 'someUnknownMethod(_)'. -------------------------------------------------------------------------------- /test/language/method/static_method_not_found.wren: -------------------------------------------------------------------------------- 1 | class Foo {} 2 | 3 | Foo.bar // expect runtime error: Foo metaclass does not implement 'bar'. -------------------------------------------------------------------------------- /test/language/method/subscript_setter_too_many_arguments.wren: -------------------------------------------------------------------------------- 1 | var list = [] 2 | list[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] = 17 // expect error 3 | -------------------------------------------------------------------------------- /test/language/method/subscript_too_many_arguments.wren: -------------------------------------------------------------------------------- 1 | var list = [] 2 | list[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] // expect error 3 | -------------------------------------------------------------------------------- /test/language/method/too_many_arguments.wren: -------------------------------------------------------------------------------- 1 | System.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17) // expect error 2 | -------------------------------------------------------------------------------- /test/language/method/too_many_parameters.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | // 17 parameters. 3 | method(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) { "!" } // expect error 4 | } 5 | -------------------------------------------------------------------------------- /test/language/module/change_imported_value/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | var Module = "before" 3 | 4 | class Other { 5 | static change { 6 | Module = "after" 7 | } 8 | 9 | static show { 10 | System.print(Module) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/language/module/compile_error/compile_error.wren: -------------------------------------------------------------------------------- 1 | System.print("before") // expect: before 2 | import "./module" for Module // expect runtime error: Could not compile module './test/language/module/compile_error/module'. 3 | -------------------------------------------------------------------------------- /test/language/module/compile_error/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | undefined 3 | -------------------------------------------------------------------------------- /test/language/module/cyclic_import/a.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("start a") 3 | 4 | var A = "a value" 5 | System.print("a defined %(A)") 6 | import "./b" for B 7 | System.print("a imported %(B)") 8 | 9 | System.print("end a") 10 | -------------------------------------------------------------------------------- /test/language/module/cyclic_import/b.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("start b") 3 | 4 | var B = "b value" 5 | System.print("b defined %(B)") 6 | import "./a" for A 7 | System.print("b imported %(A)") 8 | 9 | System.print("end b") 10 | -------------------------------------------------------------------------------- /test/language/module/cyclic_import/cyclic_import.wren: -------------------------------------------------------------------------------- 1 | import "./a" 2 | 3 | // Shared module should only run once: 4 | // expect: start a 5 | // expect: a defined a value 6 | // expect: start b 7 | // expect: b defined b value 8 | // expect: b imported a value 9 | // expect: end b 10 | // expect: a imported b value 11 | // expect: end a -------------------------------------------------------------------------------- /test/language/module/import_as/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | var Module = "from module" 3 | System.print("ran module") 4 | 5 | var ValueA = "module A" 6 | var ValueB = "module B" 7 | var ValueC = "module C" -------------------------------------------------------------------------------- /test/language/module/inside_block/inside_block.wren: -------------------------------------------------------------------------------- 1 | var Module = "outer" 2 | 3 | if (true) { 4 | import "./module" for Module 5 | // expect: ran module 6 | 7 | System.print(Module) // expect: from module 8 | } 9 | 10 | System.print(Module) // expect: outer 11 | -------------------------------------------------------------------------------- /test/language/module/inside_block/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | var Module = "from module" 3 | System.print("ran module") 4 | -------------------------------------------------------------------------------- /test/language/module/missing_for.wren: -------------------------------------------------------------------------------- 1 | import "./module" NoString // expect error 2 | -------------------------------------------------------------------------------- /test/language/module/missing_string_after_import.wren: -------------------------------------------------------------------------------- 1 | import for NoString // expect error 2 | -------------------------------------------------------------------------------- /test/language/module/module_dir/module_dir.wren: -------------------------------------------------------------------------------- 1 | import "./something/module" for Index 2 | 3 | System.print(Index) // expect: index -------------------------------------------------------------------------------- /test/language/module/module_dir/something/module.wren: -------------------------------------------------------------------------------- 1 | var Index = "index" -------------------------------------------------------------------------------- /test/language/module/multiple_variables/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | var Module1 = "from module one" 3 | var Module2 = "from module two" 4 | var Module3 = "from module three" 5 | var Module4 = "from module four" 6 | var Module5 = "from module five" 7 | 8 | System.print("ran module") 9 | -------------------------------------------------------------------------------- /test/language/module/name_collision.wren: -------------------------------------------------------------------------------- 1 | var Collides 2 | import "./module" for Collides // expect error 3 | -------------------------------------------------------------------------------- /test/language/module/newlines/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("ran module") 3 | 4 | var A = "a" 5 | var B = "b" -------------------------------------------------------------------------------- /test/language/module/newlines/newlines.wren: -------------------------------------------------------------------------------- 1 | import 2 | 3 | 4 | "./module" 5 | 6 | import "./module" for 7 | 8 | A, 9 | 10 | B 11 | 12 | // expect: ran module 13 | 14 | System.print(A) // expect: a 15 | System.print(B) // expect: b 16 | -------------------------------------------------------------------------------- /test/language/module/no_variable/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("ran module") 3 | -------------------------------------------------------------------------------- /test/language/module/no_variable/no_variable.wren: -------------------------------------------------------------------------------- 1 | import "./module" 2 | // expect: ran module 3 | -------------------------------------------------------------------------------- /test/language/module/relative_import/module_3.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("module_3") 3 | -------------------------------------------------------------------------------- /test/language/module/relative_import/relative_import.wren: -------------------------------------------------------------------------------- 1 | import "./sub/module" 2 | import "./sub/././///dir/module" 3 | // expect: sub/module 4 | // expect: sub/module_2 5 | // expect: sub/dir/module 6 | // expect: sub/dir/module_2 7 | // expect: sub/module_3 8 | // expect: module_3 9 | -------------------------------------------------------------------------------- /test/language/module/relative_import/sub/dir/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("sub/dir/module") 3 | import "./module_2" 4 | -------------------------------------------------------------------------------- /test/language/module/relative_import/sub/dir/module_2.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("sub/dir/module_2") 3 | import "../module_3" 4 | import "../../module_3" 5 | -------------------------------------------------------------------------------- /test/language/module/relative_import/sub/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("sub/module") 3 | import "./module_2" 4 | -------------------------------------------------------------------------------- /test/language/module/relative_import/sub/module_2.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("sub/module_2") 3 | -------------------------------------------------------------------------------- /test/language/module/relative_import/sub/module_3.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("sub/module_3") 3 | -------------------------------------------------------------------------------- /test/language/module/returns/module_return.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("foo") 3 | return 4 | System.print("bar") 5 | -------------------------------------------------------------------------------- /test/language/module/returns/module_return_value.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("foo") 3 | return 42 4 | System.print("bar") 5 | -------------------------------------------------------------------------------- /test/language/module/returns/return.wren: -------------------------------------------------------------------------------- 1 | System.print("foo") // expect: foo 2 | return 3 | System.print("bar") 4 | -------------------------------------------------------------------------------- /test/language/module/returns/return_from_import.wren: -------------------------------------------------------------------------------- 1 | import "./module_return" 2 | 3 | System.print("baz") 4 | // expect: foo 5 | // expect: baz 6 | -------------------------------------------------------------------------------- /test/language/module/returns/return_value.wren: -------------------------------------------------------------------------------- 1 | System.print("foo") // expect: foo 2 | return 42 3 | System.print("bar") 4 | -------------------------------------------------------------------------------- /test/language/module/returns/return_value_from_import.wren: -------------------------------------------------------------------------------- 1 | import "./module_return_value" 2 | 3 | System.print("baz") 4 | // expect: foo 5 | // expect: baz 6 | -------------------------------------------------------------------------------- /test/language/module/shared_import/a.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("a") 3 | import "./shared" for Shared 4 | var A = "a %(Shared)" 5 | System.print("a done") 6 | -------------------------------------------------------------------------------- /test/language/module/shared_import/b.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("b") 3 | import "./shared" for Shared 4 | var B = "b %(Shared)" 5 | System.print("b done") 6 | -------------------------------------------------------------------------------- /test/language/module/shared_import/shared.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | System.print("shared") 3 | var Shared = "shared" 4 | -------------------------------------------------------------------------------- /test/language/module/shared_import/shared_import.wren: -------------------------------------------------------------------------------- 1 | import "./a" for A 2 | import "./b" for B 3 | 4 | // Shared module should only run once: 5 | // expect: a 6 | // expect: shared 7 | // expect: a done 8 | // expect: b 9 | // expect: b done 10 | 11 | System.print(A) // expect: a shared 12 | System.print(B) // expect: b shared 13 | -------------------------------------------------------------------------------- /test/language/module/simple_import/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | var Module = "from module" 3 | System.print("ran module") 4 | -------------------------------------------------------------------------------- /test/language/module/simple_import/simple_import.wren: -------------------------------------------------------------------------------- 1 | import "./module" for Module 2 | // expect: ran module 3 | 4 | System.print(Module) // expect: from module 5 | -------------------------------------------------------------------------------- /test/language/module/unknown_module.wren: -------------------------------------------------------------------------------- 1 | import "./does_not_exist" for DoesNotExist // expect runtime error: Could not load module './test/language/module/does_not_exist'. 2 | -------------------------------------------------------------------------------- /test/language/module/unknown_variable/module.wren: -------------------------------------------------------------------------------- 1 | // nontest 2 | var Module = "from module" 3 | System.print("ran module") 4 | -------------------------------------------------------------------------------- /test/language/module/unknown_variable/unknown_variable.wren: -------------------------------------------------------------------------------- 1 | // Should execute the module: 2 | // expect: ran module 3 | import "./module" for DoesNotExist // expect runtime error: Could not find a variable named 'DoesNotExist' in module './test/language/module/unknown_variable/module'. 4 | -------------------------------------------------------------------------------- /test/language/no_trailing_newline.wren: -------------------------------------------------------------------------------- 1 | System.print("ok") // expect: ok -------------------------------------------------------------------------------- /test/language/nonlocal/duplicate_nonlocal.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar { 3 | var A = "value" 4 | var A = "other" // expect error 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/language/nonlocal/in_block_scope.wren: -------------------------------------------------------------------------------- 1 | var Nonlocal = "outer" 2 | 3 | { 4 | var Nonlocal = "inner" 5 | System.print(Nonlocal) // expect: inner 6 | } 7 | 8 | System.print(Nonlocal) // expect: outer 9 | -------------------------------------------------------------------------------- /test/language/nonlocal/localname_forward_declare.wren: -------------------------------------------------------------------------------- 1 | if (false) { 2 | System.print(a) 3 | } 4 | 5 | var a = 123 // expect error: Error at '123': Variable 'a' referenced before this definition (first use at line 2). -------------------------------------------------------------------------------- /test/language/nonlocal/mutual_recursion.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | static bar { Bar.new() } 4 | } 5 | 6 | class Bar { 7 | construct new() {} 8 | static foo { Foo.new() } 9 | } 10 | 11 | System.print(Foo.bar) // expect: instance of Bar 12 | System.print(Bar.foo) // expect: instance of Foo 13 | -------------------------------------------------------------------------------- /test/language/nonlocal/nonlocal_in_initializer.wren: -------------------------------------------------------------------------------- 1 | var A = A == null 2 | System.print(A) // expect: true 3 | -------------------------------------------------------------------------------- /test/language/nonlocal/nonlocal_without_initializer.wren: -------------------------------------------------------------------------------- 1 | var A 2 | System.print(A) // expect: null 3 | -------------------------------------------------------------------------------- /test/language/nonlocal/null_before_defined.wren: -------------------------------------------------------------------------------- 1 | System.print(Foo) // expect: null 2 | var Foo = "value" 3 | System.print(Foo) // expect: value 4 | -------------------------------------------------------------------------------- /test/language/nonlocal/undefined.wren: -------------------------------------------------------------------------------- 1 | var fn = Fn.new { 2 | System.print(Foo) // expect error 3 | System.print(Bar) // expect error 4 | } 5 | -------------------------------------------------------------------------------- /test/language/nonlocal/use_in_function.wren: -------------------------------------------------------------------------------- 1 | var Global = "global" 2 | 3 | Fn.new { 4 | System.print(Global) // expect: global 5 | }.call() 6 | -------------------------------------------------------------------------------- /test/language/nonlocal/use_in_function_before_definition.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | System.print(Global) 3 | } 4 | 5 | var Global = "global" 6 | 7 | f.call() // expect: global -------------------------------------------------------------------------------- /test/language/nonlocal/use_in_method.wren: -------------------------------------------------------------------------------- 1 | var Global = "global" 2 | 3 | class Foo { 4 | construct new() {} 5 | 6 | method { 7 | System.print(Global) 8 | } 9 | 10 | static classMethod { 11 | System.print(Global) 12 | } 13 | } 14 | 15 | Foo.new().method // expect: global 16 | Foo.classMethod // expect: global 17 | -------------------------------------------------------------------------------- /test/language/nonlocal/use_in_method_before_definition.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | 4 | method { 5 | System.print(Global) 6 | } 7 | 8 | static classMethod { 9 | System.print(Global) 10 | } 11 | } 12 | 13 | var Global = "global" 14 | 15 | Foo.new().method // expect: global 16 | Foo.classMethod // expect: global 17 | -------------------------------------------------------------------------------- /test/language/null/literal.wren: -------------------------------------------------------------------------------- 1 | System.print(null) // expect: null 2 | -------------------------------------------------------------------------------- /test/language/number/hex_literals.wren: -------------------------------------------------------------------------------- 1 | var x = 0xFF 2 | 3 | System.print(x) // expect: 255 4 | System.print(x + 1) // expect: 256 5 | System.print(x == 255) // expect: true 6 | System.print(0x09 is Num) // expect: true 7 | System.print(x is Num) // expect: true 8 | System.print(-0xFF) // expect: -255 9 | System.print(0xdeadbeef) // expect: 3735928559 10 | -------------------------------------------------------------------------------- /test/language/number/hex_too_large.wren: -------------------------------------------------------------------------------- 1 | var x = 0x999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 // expect error 2 | -------------------------------------------------------------------------------- /test/language/number/literal_too_large.wren: -------------------------------------------------------------------------------- 1 | var x = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 // expect error 2 | -------------------------------------------------------------------------------- /test/language/number/literals.wren: -------------------------------------------------------------------------------- 1 | System.print(123) // expect: 123 2 | System.print(987654) // expect: 987654 3 | System.print(0) // expect: 0 4 | System.print(-0) // expect: -0 5 | 6 | System.print(123.456) // expect: 123.456 7 | System.print(-0.001) // expect: -0.001 8 | 9 | // TODO: Literals at and beyond numeric limits. 10 | -------------------------------------------------------------------------------- /test/language/number/scientific_float_missing_exponent.wren: -------------------------------------------------------------------------------- 1 | var x = 1.2e // expect error 2 | -------------------------------------------------------------------------------- /test/language/number/scientific_floating_exponent.wren: -------------------------------------------------------------------------------- 1 | var x = 1.2e3.4 // expect error 2 | -------------------------------------------------------------------------------- /test/language/number/scientific_missing_exponent.wren: -------------------------------------------------------------------------------- 1 | var x = 1e // expect error 2 | -------------------------------------------------------------------------------- /test/language/number/scientific_missing_fractional_part.wren: -------------------------------------------------------------------------------- 1 | var x = 1.e // expect runtime error: Num does not implement 'e'. -------------------------------------------------------------------------------- /test/language/number/scientific_multiple_exponants.wren: -------------------------------------------------------------------------------- 1 | var x = 1.2e3e4 // expect error 2 | -------------------------------------------------------------------------------- /test/language/number/scientific_multiple_exponent_signs.wren: -------------------------------------------------------------------------------- 1 | var x = 1e+-01 // expect error 2 | -------------------------------------------------------------------------------- /test/language/return/after_else.wren: -------------------------------------------------------------------------------- 1 | System.print(Fn.new { 2 | if (false) "no" else return "ok" 3 | }.call()) // expect: ok 4 | -------------------------------------------------------------------------------- /test/language/return/after_if.wren: -------------------------------------------------------------------------------- 1 | System.print(Fn.new { 2 | if (true) return "ok" 3 | }.call()) // expect: ok 4 | -------------------------------------------------------------------------------- /test/language/return/after_while.wren: -------------------------------------------------------------------------------- 1 | System.print(Fn.new { 2 | while (true) return "ok" 3 | }.call()) // expect: ok 4 | -------------------------------------------------------------------------------- /test/language/return/in_function.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | return "ok" 3 | System.print("bad") 4 | } 5 | 6 | System.print(f.call()) // expect: ok 7 | -------------------------------------------------------------------------------- /test/language/return/in_method.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | 4 | method { 5 | return "ok" 6 | System.print("bad") 7 | } 8 | } 9 | 10 | System.print(Foo.new().method) // expect: ok 11 | -------------------------------------------------------------------------------- /test/language/return/return_null_if_newline.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | return 3 | System.print("bad") 4 | } 5 | 6 | System.print(f.call()) // expect: null 7 | -------------------------------------------------------------------------------- /test/language/semicolon.wren: -------------------------------------------------------------------------------- 1 | // Semicolons are not valid separators. 2 | var a = "ok"; System.print(a) // expect error 3 | -------------------------------------------------------------------------------- /test/language/setter/grouping.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar=(value) { value } 3 | } 4 | 5 | var foo = Foo.new() 6 | (foo.bar) = "value" // expect error 7 | -------------------------------------------------------------------------------- /test/language/setter/infix_operator.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar=(value) { value } 3 | } 4 | 5 | var foo = Foo.new() 6 | "a" + foo.bar = "value" // expect error 7 | -------------------------------------------------------------------------------- /test/language/setter/instance.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | 4 | bar=(value) { 5 | System.print(value) 6 | } 7 | } 8 | 9 | var foo = Foo.new() 10 | foo.bar = "value" // expect: value 11 | -------------------------------------------------------------------------------- /test/language/setter/is.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar=(value) { value } 3 | } 4 | 5 | var foo = Foo.new() 6 | a is foo.bar = "value" // expect error 7 | -------------------------------------------------------------------------------- /test/language/setter/prefix_operator.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar=(value) { value } 3 | } 4 | 5 | var foo = Foo.new() 6 | !foo.bar = "value" // expect error 7 | -------------------------------------------------------------------------------- /test/language/setter/result.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | bar=(value) { "result" } 4 | } 5 | 6 | var foo = Foo.new() 7 | System.print(foo.bar = "value") // expect: result 8 | -------------------------------------------------------------------------------- /test/language/setter/same_name_as_method.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | bar=(value) { System.print("set") } 4 | bar { System.print("get") } 5 | } 6 | 7 | var foo = Foo.new() 8 | foo.bar = "value" // expect: set 9 | foo.bar // expect: get 10 | -------------------------------------------------------------------------------- /test/language/setter/static.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static bar=(value) { 3 | System.print(value) 4 | } 5 | } 6 | 7 | Foo.bar = "value" // expect: value 8 | -------------------------------------------------------------------------------- /test/language/shebang/shebang.wren: -------------------------------------------------------------------------------- 1 | #!/bin/wren 2 | System.print("ok") // expect: ok 3 | -------------------------------------------------------------------------------- /test/language/shebang/shebang_at_eof.wren: -------------------------------------------------------------------------------- 1 | #!/bin/wren -------------------------------------------------------------------------------- /test/language/shebang/shebang_at_other_line.wren: -------------------------------------------------------------------------------- 1 | // expect error line 3 2 | System.print("nope") 3 | #!/bin/wren -------------------------------------------------------------------------------- /test/language/shebang/shebang_invalid.wren: -------------------------------------------------------------------------------- 1 | #/invalid/shebang 2 | // expect error line 1 3 | System.print("nope") 4 | -------------------------------------------------------------------------------- /test/language/static_field/default_to_null.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static write { System.print(__field) } 3 | } 4 | 5 | Foo.write // expect: null 6 | -------------------------------------------------------------------------------- /test/language/static_field/outside_class.wren: -------------------------------------------------------------------------------- 1 | __field = "wat" // expect error 2 | -------------------------------------------------------------------------------- /test/language/static_field/use_before_set.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static write { System.print(__field) } // Compile a use of the field... 3 | static init { __field = "value" } // ...before an assignment to it. 4 | } 5 | 6 | // But invoke them in the right order. 7 | Foo.init 8 | Foo.write // expect: value 9 | -------------------------------------------------------------------------------- /test/language/string/escapes.wren: -------------------------------------------------------------------------------- 1 | // Escape characters. 2 | System.print("\"") // expect: " 3 | System.print("\\") // expect: \ 4 | System.print("(\n)") // expect: ( 5 | // expect: ) 6 | System.print("\%") // expect: % 7 | 8 | // TODO: Non-printing escapes like \t. 9 | -------------------------------------------------------------------------------- /test/language/string/incomplete_byte_escape.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "\x0" -------------------------------------------------------------------------------- /test/language/string/incomplete_byte_escape_at_eof.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "\x0 -------------------------------------------------------------------------------- /test/language/string/incomplete_long_unicode_escape.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "\U01F603" 3 | -------------------------------------------------------------------------------- /test/language/string/incomplete_unicode_escape.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "\u00" -------------------------------------------------------------------------------- /test/language/string/incomplete_unicode_escape_at_eof.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "\u004 -------------------------------------------------------------------------------- /test/language/string/invalid_byte_escape.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "\x0!" -------------------------------------------------------------------------------- /test/language/string/invalid_escape.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "not a \m real escape" -------------------------------------------------------------------------------- /test/language/string/invalid_unicode_escape.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "\u00no" -------------------------------------------------------------------------------- /test/language/string/unicode_two_bytes_to_long_escape.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "\U0060" 3 | -------------------------------------------------------------------------------- /test/language/string/unterminated.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | "this string has no close quote -------------------------------------------------------------------------------- /test/language/string/unterminated_raw.wren: -------------------------------------------------------------------------------- 1 | // expect error line 2 2 | """this string has no close quote -------------------------------------------------------------------------------- /test/language/super/call_same_method.wren: -------------------------------------------------------------------------------- 1 | class Base { 2 | foo { 3 | System.print("Base.foo") 4 | } 5 | } 6 | 7 | class Derived is Base { 8 | construct new() {} 9 | 10 | foo { 11 | System.print("Derived.foo") 12 | super.foo 13 | } 14 | } 15 | 16 | Derived.new().foo 17 | // expect: Derived.foo 18 | // expect: Base.foo 19 | -------------------------------------------------------------------------------- /test/language/super/closure.wren: -------------------------------------------------------------------------------- 1 | class Base { 2 | toString { "Base" } 3 | } 4 | 5 | class Derived is Base { 6 | construct new() {} 7 | getClosure { Fn.new { super.toString } } 8 | toString { "Derived" } 9 | } 10 | 11 | var closure = Derived.new().getClosure 12 | System.print(closure.call()) // expect: Base 13 | -------------------------------------------------------------------------------- /test/language/super/implicit_name.wren: -------------------------------------------------------------------------------- 1 | class Base { 2 | foo { 3 | System.print("Base.foo") 4 | } 5 | } 6 | 7 | class Derived is Base { 8 | construct new() {} 9 | 10 | foo { 11 | System.print("Derived.foo") 12 | super 13 | } 14 | } 15 | 16 | Derived.new().foo 17 | // expect: Derived.foo 18 | // expect: Base.foo 19 | -------------------------------------------------------------------------------- /test/language/super/indirectly_inherited.wren: -------------------------------------------------------------------------------- 1 | class A { 2 | foo { 3 | System.print("A.foo") 4 | } 5 | } 6 | 7 | class B is A {} 8 | 9 | class C is B { 10 | construct new() {} 11 | 12 | foo { 13 | System.print("C.foo") 14 | super.foo 15 | } 16 | } 17 | 18 | C.new().foo 19 | // expect: C.foo 20 | // expect: A.foo 21 | -------------------------------------------------------------------------------- /test/language/super/no_superclass_method.wren: -------------------------------------------------------------------------------- 1 | class Base {} 2 | 3 | class Derived is Base { 4 | construct new() {} 5 | foo { super.doesNotExist(1) } // expect runtime error: Base does not implement 'doesNotExist(_)'. 6 | } 7 | 8 | Derived.new().foo 9 | -------------------------------------------------------------------------------- /test/language/super/super_at_top_level.wren: -------------------------------------------------------------------------------- 1 | super.foo // expect error 2 | super // expect error 3 | super.foo("bar") // expect error 4 | super("foo") // expect error 5 | -------------------------------------------------------------------------------- /test/language/super/super_in_closure_in_inherited_method.wren: -------------------------------------------------------------------------------- 1 | class A { 2 | callSuperToString { 3 | return Fn.new { super.toString }.call() 4 | } 5 | 6 | toString { "A.toString" } 7 | } 8 | 9 | class B is A { 10 | construct new() {} 11 | } 12 | 13 | System.print(B.new().callSuperToString) // expect: instance of B 14 | -------------------------------------------------------------------------------- /test/language/super/super_in_inherited_method.wren: -------------------------------------------------------------------------------- 1 | class A { 2 | callSuperToString { super.toString } 3 | 4 | toString { "A.toString" } 5 | } 6 | 7 | class B is A { 8 | construct new() {} 9 | } 10 | 11 | System.print(B.new().callSuperToString) // expect: instance of B 12 | -------------------------------------------------------------------------------- /test/language/super/super_in_static_method.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static name { 3 | System.print("Foo.name") // expect: Foo.name 4 | System.print(super) // expect: Foo 5 | } 6 | } 7 | 8 | Foo.name 9 | -------------------------------------------------------------------------------- /test/language/super/super_in_top_level_function.wren: -------------------------------------------------------------------------------- 1 | Fn.new { 2 | super.foo // expect error 3 | } 4 | -------------------------------------------------------------------------------- /test/language/this/closure.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | getClosure { Fn.new { toString } } 4 | toString { "Foo" } 5 | } 6 | 7 | var closure = Foo.new().getClosure 8 | System.print(closure.call()) // expect: Foo 9 | -------------------------------------------------------------------------------- /test/language/this/nested_closure.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | getClosure { Fn.new { Fn.new { Fn.new { toString } } } } 4 | toString { "Foo" } 5 | } 6 | 7 | var closure = Foo.new().getClosure 8 | System.print(closure.call().call().call()) // expect: Foo 9 | -------------------------------------------------------------------------------- /test/language/this/this_at_top_level.wren: -------------------------------------------------------------------------------- 1 | this // expect error 2 | -------------------------------------------------------------------------------- /test/language/this/this_in_method.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | construct new() {} 3 | bar { this } 4 | baz { "baz" } 5 | } 6 | 7 | System.print(Foo.new().bar.baz) // expect: baz 8 | -------------------------------------------------------------------------------- /test/language/this/this_in_static_method.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | static test { 3 | System.print(this == Foo) // expect: true 4 | System.print(this.bar) // expect: bar 5 | } 6 | 7 | static bar { "bar" } 8 | } 9 | 10 | Foo.test 11 | -------------------------------------------------------------------------------- /test/language/this/this_in_top_level_function.wren: -------------------------------------------------------------------------------- 1 | Fn.new { 2 | this // expect error 3 | } 4 | -------------------------------------------------------------------------------- /test/language/unexpected_character.wren: -------------------------------------------------------------------------------- 1 | System.print("no") 2 | // Something that's not a valid character: 3 | ^ // expect error 4 | -------------------------------------------------------------------------------- /test/language/variable/duplicate_local.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar { 3 | var a = "value" 4 | var a = "other" // expect error 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/language/variable/duplicate_parameter.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar(arg, 3 | arg) { // expect error 4 | "body" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/language/variable/global_in_initializer.wren: -------------------------------------------------------------------------------- 1 | var a = a == null // expect error 2 | -------------------------------------------------------------------------------- /test/language/variable/global_without_initializer.wren: -------------------------------------------------------------------------------- 1 | var a 2 | System.print(a) // expect: null 3 | -------------------------------------------------------------------------------- /test/language/variable/local_collide_with_function_parameter.wren: -------------------------------------------------------------------------------- 1 | Fn.new {|a| 2 | var a = "oops" // expect error 3 | } 4 | -------------------------------------------------------------------------------- /test/language/variable/local_collide_with_method_parameter.wren: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar(a) { 3 | var a = "oops" // expect error 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/language/variable/local_in_initializer.wren: -------------------------------------------------------------------------------- 1 | { 2 | var a = a + 1 // expect error 3 | System.print(a) 4 | } 5 | -------------------------------------------------------------------------------- /test/language/variable/local_in_nested_block.wren: -------------------------------------------------------------------------------- 1 | { 2 | var a = "outer" 3 | { 4 | System.print(a) // expect: outer 5 | } 6 | } -------------------------------------------------------------------------------- /test/language/variable/local_without_initializer.wren: -------------------------------------------------------------------------------- 1 | { 2 | var a 3 | System.print(a) // expect: null 4 | } 5 | -------------------------------------------------------------------------------- /test/language/variable/newline_after_equals.wren: -------------------------------------------------------------------------------- 1 | var foo = 2 | 3 | 4 | 123 5 | System.print(foo) // expect: 123 6 | -------------------------------------------------------------------------------- /test/language/variable/newline_after_var.wren: -------------------------------------------------------------------------------- 1 | var // expect error 2 | foo = 123 -------------------------------------------------------------------------------- /test/language/variable/scope_if.wren: -------------------------------------------------------------------------------- 1 | // Create a local scope for the 'then' expression. 2 | var a = "out" 3 | if (true) { 4 | var a = "in" 5 | } 6 | System.print(a) // expect: out 7 | 8 | // Create a local scope for the 'else' expression. 9 | var b = "out" 10 | if (false) "dummy" else { 11 | var b = "in" 12 | } 13 | System.print(b) // expect: out 14 | -------------------------------------------------------------------------------- /test/language/variable/scope_reuse_in_different_blocks.wren: -------------------------------------------------------------------------------- 1 | { 2 | var a = "first" 3 | System.print(a) // expect: first 4 | } 5 | 6 | { 7 | var a = "second" 8 | System.print(a) // expect: second 9 | } 10 | -------------------------------------------------------------------------------- /test/language/variable/scope_while.wren: -------------------------------------------------------------------------------- 1 | // Body has its own scope. 2 | var a = "outer" 3 | var i = 0 4 | while ((i = i + 1) <= 1) { 5 | var a = "inner" 6 | } 7 | System.print(a) // expect: outer 8 | -------------------------------------------------------------------------------- /test/language/variable/shadow_and_local.wren: -------------------------------------------------------------------------------- 1 | { 2 | var a = "outer" 3 | { 4 | System.print(a) // expect: outer 5 | var a = "inner" 6 | System.print(a) // expect: inner 7 | } 8 | } -------------------------------------------------------------------------------- /test/language/variable/shadow_global.wren: -------------------------------------------------------------------------------- 1 | var a = "global" 2 | { 3 | var a = "shadow" 4 | System.print(a) // expect: shadow 5 | } 6 | System.print(a) // expect: global -------------------------------------------------------------------------------- /test/language/variable/shadow_in_initializer.wren: -------------------------------------------------------------------------------- 1 | { 2 | var a = "outer" 3 | { 4 | var a = a + " inner" 5 | System.print(a) // expect: outer inner 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/language/variable/shadow_local.wren: -------------------------------------------------------------------------------- 1 | { 2 | var a = "local" 3 | { 4 | var a = "shadow" 5 | System.print(a) // expect: shadow 6 | } 7 | System.print(a) // expect: local 8 | } -------------------------------------------------------------------------------- /test/language/variable/undefined_global.wren: -------------------------------------------------------------------------------- 1 | System.print(notDefined) // expect error 2 | -------------------------------------------------------------------------------- /test/language/variable/undefined_local.wren: -------------------------------------------------------------------------------- 1 | Fn.new { 2 | System.print(notDefined) // expect error 3 | }.call() 4 | -------------------------------------------------------------------------------- /test/language/variable/use_false_as_var.wren: -------------------------------------------------------------------------------- 1 | var false = "value" // expect error 2 | -------------------------------------------------------------------------------- /test/language/variable/use_field_as_var.wren: -------------------------------------------------------------------------------- 1 | var _field = "value" // expect error 2 | -------------------------------------------------------------------------------- /test/language/variable/use_null_as_var.wren: -------------------------------------------------------------------------------- 1 | var null = "value" // expect error 2 | -------------------------------------------------------------------------------- /test/language/variable/use_this_as_var.wren: -------------------------------------------------------------------------------- 1 | var this = "value" // expect error 2 | -------------------------------------------------------------------------------- /test/language/variable/use_true_as_var.wren: -------------------------------------------------------------------------------- 1 | var true = "value" // expect error 2 | -------------------------------------------------------------------------------- /test/language/while/closure_in_body.wren: -------------------------------------------------------------------------------- 1 | var list = [] 2 | 3 | var i = 1 4 | while (i < 4) { 5 | var j = i + 1 6 | list.add(Fn.new { System.print(j) }) 7 | i = i + 1 8 | } 9 | 10 | for (f in list) f.call() 11 | // expect: 2 12 | // expect: 3 13 | // expect: 4 14 | -------------------------------------------------------------------------------- /test/language/while/newline_after_while.wren: -------------------------------------------------------------------------------- 1 | while // expect error 2 | (true) System.print("bad") 3 | -------------------------------------------------------------------------------- /test/language/while/return_closure.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | while (true) { 3 | var i = "i" 4 | return Fn.new { System.print(i) } 5 | } 6 | } 7 | 8 | var g = f.call() 9 | g.call() 10 | // expect: i 11 | -------------------------------------------------------------------------------- /test/language/while/return_inside.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new { 2 | while (true) { 3 | var i = "i" 4 | return i 5 | } 6 | } 7 | 8 | System.print(f.call()) 9 | // expect: i 10 | -------------------------------------------------------------------------------- /test/language/while/syntax.wren: -------------------------------------------------------------------------------- 1 | // Single-expression body. 2 | var c = 0 3 | while (c < 3) System.print(c = c + 1) 4 | // expect: 1 5 | // expect: 2 6 | // expect: 3 7 | 8 | // Block body. 9 | var a = 0 10 | while (a < 3) { 11 | System.print(a) 12 | a = a + 1 13 | } 14 | // expect: 0 15 | // expect: 1 16 | // expect: 2 17 | -------------------------------------------------------------------------------- /test/limit/interpolation_nesting.wren: -------------------------------------------------------------------------------- 1 | System.print("0 %("1 %("2 %("3 %("4 %("5 %("6 %("7 %(8)")")")")")")")") // expect: 0 1 2 3 4 5 6 7 8 2 | -------------------------------------------------------------------------------- /test/limit/long_variable_name.wren: -------------------------------------------------------------------------------- 1 | var i234567890i234567890i234567890i234567890i234567890i234 = "value" 2 | class c234567890c234567890c234567890c234567890c234567890c234567890c234 {} 3 | -------------------------------------------------------------------------------- /test/limit/too_many_function_parameters.wren: -------------------------------------------------------------------------------- 1 | var f = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q| "!" } // expect error 2 | -------------------------------------------------------------------------------- /test/limit/too_much_interpolation_nesting.wren: -------------------------------------------------------------------------------- 1 | System.print("0 %("1 %("2 %("3 %("4 %("5 %("6 %("7 %("8 %(9)")")")")")")")")") // expect error 2 | -------------------------------------------------------------------------------- /test/limit/variable_name_too_long.wren: -------------------------------------------------------------------------------- 1 | var i234567890i234567890i234567890i234567890i234567890i234567890i2345 = "value" // expect error 2 | class c234567890c234567890c234567890c234567890c234567890c234567890c2345 {} // expect error 3 | -------------------------------------------------------------------------------- /test/meta/eval_compile_error.wren: -------------------------------------------------------------------------------- 1 | import "meta" for Meta 2 | 3 | Meta.eval("!!") // expect runtime error: Could not compile source code. 4 | -------------------------------------------------------------------------------- /test/meta/eval_existing_scoped_variable.wren: -------------------------------------------------------------------------------- 1 | import "meta" for Meta 2 | 3 | var y 4 | 5 | Meta.eval("y = 2") 6 | 7 | System.print(y) // expect: 2 -------------------------------------------------------------------------------- /test/meta/eval_not_string.wren: -------------------------------------------------------------------------------- 1 | import "meta" for Meta 2 | 3 | Meta.eval(123) // expect runtime error: Source code must be a string. 4 | -------------------------------------------------------------------------------- /test/meta/get_module_variables_not_string.wren: -------------------------------------------------------------------------------- 1 | import "meta" for Meta 2 | 3 | Meta.getModuleVariables(123) // expect runtime error: Module name must be a string. 4 | -------------------------------------------------------------------------------- /test/meta/get_module_variables_unknown_module.wren: -------------------------------------------------------------------------------- 1 | import "meta" for Meta 2 | 3 | Meta.getModuleVariables("unknown") // expect runtime error: Could not find a module named 'unknown'. 4 | -------------------------------------------------------------------------------- /test/random/float.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new(12345) 4 | 5 | var below = 0 6 | for (i in 1..1000) { 7 | var n = random.float() 8 | if (n < 0.5) below = below + 1 9 | } 10 | 11 | // Should be roughly evenly distributed. 12 | System.print(below > 450) // expect: true 13 | System.print(below < 550) // expect: true 14 | -------------------------------------------------------------------------------- /test/random/float_max.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new(12345) 4 | 5 | var below = 0 6 | for (i in 1..100) { 7 | var n = random.float(5) 8 | if (n < 0) System.print("too low") 9 | if (n >= 5) System.print("too high") 10 | } 11 | -------------------------------------------------------------------------------- /test/random/float_min_max.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new(12345) 4 | 5 | var below = 0 6 | for (i in 1..100) { 7 | var n = random.float(2, 5) 8 | if (n < 2) System.print("too low") 9 | if (n >= 5) System.print("too high") 10 | } 11 | -------------------------------------------------------------------------------- /test/random/int.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new(12345) 4 | 5 | var below = 0 6 | for (i in 1..1000) { 7 | var n = random.int() 8 | if (n < 2147483648) below = below + 1 9 | } 10 | 11 | // Should be roughly evenly distributed. 12 | System.print(below > 450) // expect: true 13 | System.print(below < 550) // expect: true 14 | -------------------------------------------------------------------------------- /test/random/int_max.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new(12345) 4 | 5 | var counts = [0, 0, 0, 0, 0] 6 | for (i in 1..10000) { 7 | var n = random.int(5) 8 | counts[n] = counts[n] + 1 9 | } 10 | 11 | for (count in counts) { 12 | if (count < 1900) System.print("too few") 13 | if (count > 2100) System.print("too many") 14 | } 15 | -------------------------------------------------------------------------------- /test/random/new.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new() 4 | 5 | var correct = 0 6 | for (i in 1..100) { 7 | var n = random.float() 8 | if (n >= 0) correct = correct + 1 9 | if (n < 1) correct = correct + 1 10 | } 11 | 12 | System.print(correct) // expect: 200 13 | -------------------------------------------------------------------------------- /test/random/new_empty_sequence.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | Random.new([]) // expect runtime error: Sequence cannot be empty. 4 | -------------------------------------------------------------------------------- /test/random/new_number.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random1 = Random.new(123) 4 | var random2 = Random.new(123) 5 | 6 | var correct = 0 7 | for (i in 1..100) { 8 | // Should produce the same values. 9 | if (random1.float() == random2.float()) correct = correct + 1 10 | } 11 | 12 | System.print(correct) // expect: 100 13 | -------------------------------------------------------------------------------- /test/random/new_sequence.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random1 = Random.new([1, 2, 3]) 4 | var random2 = Random.new([1, 2, 3]) 5 | 6 | var correct = 0 7 | for (i in 1..100) { 8 | // Should produce the same values. 9 | if (random1.float() == random2.float()) correct = correct + 1 10 | } 11 | 12 | System.print(correct) // expect: 100 13 | -------------------------------------------------------------------------------- /test/random/new_wrong_arg_type.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | Random.new(false) // expect runtime error: Seed must be a number or a sequence of numbers. 4 | -------------------------------------------------------------------------------- /test/random/new_wrong_element_type.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | Random.new(["wrong type"]) // expect runtime error: Sequence elements must all be numbers. 4 | -------------------------------------------------------------------------------- /test/random/sample_count_too_many.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new(12345) 4 | 5 | random.sample([1, 2, 3], 4) // expect runtime error: Not enough elements to sample. 6 | -------------------------------------------------------------------------------- /test/random/sample_count_zero.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new(12345) 4 | 5 | System.print(random.sample([], 0)) // expect: [] 6 | System.print(random.sample([1, 2, 3], 0)) // expect: [] 7 | -------------------------------------------------------------------------------- /test/random/sample_one_empty.wren: -------------------------------------------------------------------------------- 1 | import "random" for Random 2 | 3 | var random = Random.new(12345) 4 | 5 | random.sample([]) // expect runtime error: Not enough elements to sample. 6 | -------------------------------------------------------------------------------- /test/regression/428.wren: -------------------------------------------------------------------------------- 1 | // This was crashing the compiler with an out of bounds memory access. 2 | 3 | // expect error line 6 4 | // expect error line 7 5 | Fiber.new { 6 | isDone ["", àààààààààààààààààààààààààààààààààààààààààààààààààà 7 | -------------------------------------------------------------------------------- /test/regression/429.wren: -------------------------------------------------------------------------------- 1 | // The missing "}" was not detected by the compiler and reported as an error, 2 | // so it then tried to run the resulting erroneous bytecode and crashed. 3 | 4 | // expect error line 6 5 | { 6 | System -------------------------------------------------------------------------------- /test/regression/442-000005.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000005.wren -------------------------------------------------------------------------------- /test/regression/442-000007.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000007.wren -------------------------------------------------------------------------------- /test/regression/442-000086.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000086.wren -------------------------------------------------------------------------------- /test/regression/442-000088.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000088.wren -------------------------------------------------------------------------------- /test/regression/442-000089.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000089.wren -------------------------------------------------------------------------------- /test/regression/442-000100.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000100.wren -------------------------------------------------------------------------------- /test/regression/442-000115.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000115.wren -------------------------------------------------------------------------------- /test/regression/442-000166.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000166.wren -------------------------------------------------------------------------------- /test/regression/442-000181.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000181.wren -------------------------------------------------------------------------------- /test/regression/442-000182.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000182.wren -------------------------------------------------------------------------------- /test/regression/442-000238.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000238.wren -------------------------------------------------------------------------------- /test/regression/442-000295.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000295.wren -------------------------------------------------------------------------------- /test/regression/442-000321.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000321.wren -------------------------------------------------------------------------------- /test/regression/442-000348.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000348.wren -------------------------------------------------------------------------------- /test/regression/442-000357.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000357.wren -------------------------------------------------------------------------------- /test/regression/442-000440.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000440.wren -------------------------------------------------------------------------------- /test/regression/442-000665.wren: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wren-lang/wren/77aeb12ab8cff432dcc0e0c511d0f30366650f15/test/regression/442-000665.wren -------------------------------------------------------------------------------- /test/regression/494.wren: -------------------------------------------------------------------------------- 1 | 0[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2 | // expect error line 1 3 | // expect error line 4 4 | -------------------------------------------------------------------------------- /test/unit/main.c: -------------------------------------------------------------------------------- 1 | #include "path_test.h" 2 | #include "test.h" 3 | 4 | int main() 5 | { 6 | testPath(); 7 | 8 | return showTestResults(); 9 | } 10 | -------------------------------------------------------------------------------- /test/unit/path_test.h: -------------------------------------------------------------------------------- 1 | void testPath(); 2 | -------------------------------------------------------------------------------- /test/unit/test.h: -------------------------------------------------------------------------------- 1 | // Set this to 1 to output passing tests. 2 | #define SHOW_PASSES 0 3 | 4 | void pass(); 5 | void fail(); 6 | 7 | int showTestResults(); 8 | --------------------------------------------------------------------------------