mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
remove trailing spaces
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
Copyright (c) 2014 mruby developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# mruby is using Rake (http://rake.rubyforge.org) as a build tool.
|
||||
# We provide a minimalistic version called minirake inside of our
|
||||
# We provide a minimalistic version called minirake inside of our
|
||||
# codebase.
|
||||
|
||||
RAKE = ruby ./minirake
|
||||
|
||||
@@ -68,22 +68,22 @@ documentation with examples under *examples/mrbgems*.
|
||||
|
||||
Copyright (c) 2014 mruby developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## Note for License
|
||||
@@ -91,7 +91,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
mruby has chosen a MIT License due to its permissive license allowing
|
||||
developers to target various environments such as embedded systems.
|
||||
However, the license requires the display of the copyright notice and license
|
||||
information in manuals for instance. Doing so for big projects can be
|
||||
information in manuals for instance. Doing so for big projects can be
|
||||
complicated or troublesome.
|
||||
This is why mruby has decided to display "mruby developers" as the copyright name
|
||||
to make it simple conventionally.
|
||||
|
||||
+14
-14
@@ -33,7 +33,7 @@ customized path using the *$MRUBY_CONFIG* environment variable.
|
||||
|
||||
To compile just call ```./minirake``` inside of the mruby source root. To
|
||||
generate and execute the test tools call ```./minirake test```. To clean
|
||||
all build files call ```./minirake clean```. To see full command line on
|
||||
all build files call ```./minirake clean```. To see full command line on
|
||||
build, call ```./minirake -v```.
|
||||
|
||||
## Build Configuration
|
||||
@@ -284,21 +284,21 @@ root directory. The structure of this directory will look like this:
|
||||
+- mirb
|
||||
|
|
||||
+- mrbc
|
||||
|
|
||||
|
|
||||
+- mruby
|
||||
|
||||
The compilation workflow will look like this:
|
||||
* compile all files under *src* (object files will be stored
|
||||
* compile all files under *src* (object files will be stored
|
||||
in *build/host/src*)
|
||||
* generate parser grammar out of *src/parse.y* (generated
|
||||
result will be stored in *build/host/src/y.tab.c*)
|
||||
* compile *build/host/src/y.tab.c* to *build/host/src/y.tab.o*
|
||||
* create *build/host/lib/libmruby_core.a* out of all object files (C only)
|
||||
* create ```build/host/bin/mrbc``` by compiling *tools/mrbc/mrbc.c* and
|
||||
linking with *build/host/lib/libmruby_core.a*
|
||||
linking with *build/host/lib/libmruby_core.a*
|
||||
* create *build/host/mrblib/mrblib.c* by compiling all \*.rb files
|
||||
under *mrblib* with ```build/host/bin/mrbc```
|
||||
* compile *build/host/mrblib/mrblib.c* to *build/host/mrblib/mrblib.o*
|
||||
* compile *build/host/mrblib/mrblib.c* to *build/host/mrblib/mrblib.o*
|
||||
* create *build/host/lib/libmruby.a* out of all object files (C and Ruby)
|
||||
* create ```build/host/bin/mruby``` by compiling *mrbgems/mruby-bin-mruby/tools/mruby/mruby.c* and
|
||||
linking with *build/host/lib/libmruby.a*
|
||||
@@ -336,8 +336,8 @@ like this:
|
||||
| +- mirb
|
||||
| |
|
||||
| +- mrbc
|
||||
| |
|
||||
| +- mruby
|
||||
| |
|
||||
| +- mruby
|
||||
+- i386
|
||||
|
|
||||
+- bin <- Cross-compiled Binaries
|
||||
@@ -355,7 +355,7 @@ like this:
|
||||
+- mirb
|
||||
|
|
||||
+- mrbc
|
||||
|
|
||||
|
|
||||
+- mruby
|
||||
|
||||
An extra directory is created for the target platform. In case you
|
||||
@@ -365,7 +365,7 @@ build direcotry.
|
||||
The cross compilation workflow starts in the same way as the normal
|
||||
compilation by compiling all *native* libraries and binaries.
|
||||
Afterwards the cross compilation process proceeds like this:
|
||||
* cross-compile all files under *src* (object files will be stored
|
||||
* cross-compile all files under *src* (object files will be stored
|
||||
in *build/i386/src*)
|
||||
* generate parser grammar out of *src/parse.y* (generated
|
||||
result will be stored in *build/i386/src/y.tab.c*)
|
||||
@@ -380,7 +380,7 @@ linking with *build/i386/lib/libmruby.a*
|
||||
linking with *build/i386/lib/libmruby.a*
|
||||
* create *build/i386/lib/libmruby_core.a* out of all object files (C only)
|
||||
* create ```build/i386/bin/mrbc``` by cross-compiling *tools/mrbc/mrbc.c* and
|
||||
linking with *build/i386/lib/libmruby_core.a*
|
||||
linking with *build/i386/lib/libmruby_core.a*
|
||||
|
||||
```
|
||||
_______________________________________________________________
|
||||
@@ -406,15 +406,15 @@ linking with *build/i386/lib/libmruby_core.a*
|
||||
|
||||
### Minimal Library
|
||||
|
||||
To build a minimal mruby library you need to use the Cross Compiling
|
||||
feature due to the reason that there are functions (i.e. stdio) which
|
||||
To build a minimal mruby library you need to use the Cross Compiling
|
||||
feature due to the reason that there are functions (i.e. stdio) which
|
||||
can't be disabled for the main build.
|
||||
|
||||
MRuby::CrossBuild.new('Minimal') do |conf|
|
||||
toolchain :gcc
|
||||
|
||||
conf.cc.defines = %w(DISABLE_STDIO)
|
||||
conf.bins = []
|
||||
conf.bins = []
|
||||
end
|
||||
|
||||
This configuration defines a cross compile build called 'Minimal' which
|
||||
@@ -426,5 +426,5 @@ all usages of stdio and doesn't compile any binaries (i.e. mrbc).
|
||||
mruby's build process includes a test environment. In case you start the testing
|
||||
of mruby, a native binary called ```mrbtest``` will be generated and executed.
|
||||
This binary contains all test cases which are defined under *test/t*. In case
|
||||
of a cross-compilation an additional cross-compiled *mrbtest* binary is
|
||||
of a cross-compilation an additional cross-compiled *mrbtest* binary is
|
||||
generated. You can copy this binary and run on your target system.
|
||||
|
||||
+476
-476
File diff suppressed because it is too large
Load Diff
@@ -69,7 +69,7 @@ CLASS
|
||||
## #{name}
|
||||
|
||||
ISO Code | Source File
|
||||
--- | ---
|
||||
--- | ---
|
||||
#{iso} | #{file}
|
||||
|
||||
CLASS
|
||||
|
||||
@@ -25,19 +25,19 @@ A remote GIT repository location for a GEM is also supported:
|
||||
|
||||
conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
|
||||
|
||||
To pull all gems from remote GIT repository on build, call ```./minirake -p```,
|
||||
To pull all gems from remote GIT repository on build, call ```./minirake -p```,
|
||||
or ```./minirake --pull-gems```.
|
||||
|
||||
NOTE: `:bitbucket` option supports only git. Hg is unsupported in this version.
|
||||
|
||||
## GemBox
|
||||
|
||||
There are instances when you wish to add a collection of mrbgems into mruby at
|
||||
There are instances when you wish to add a collection of mrbgems into mruby at
|
||||
once, or be able to substitute mrbgems based on configuration, without having to
|
||||
add each gem to the *build_config.rb* file. A packaged collection of mrbgems
|
||||
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
|
||||
add each gem to the *build_config.rb* file. A packaged collection of mrbgems
|
||||
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
|
||||
into mruby, in the same format as if you were adding them to *build_config.rb*
|
||||
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
|
||||
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
|
||||
loaded into mruby via `config.gembox 'boxname'`.
|
||||
|
||||
Below we have created a GemBox containing *mruby-time* and *mrbgems-example*:
|
||||
@@ -51,8 +51,8 @@ As mentioned, the GemBox uses the same conventions as `MRuby::Build`. The GemBo
|
||||
must be saved with a *.gembox* extension inside the *mrbgems* directory to to be
|
||||
picked up by mruby.
|
||||
|
||||
To use this example GemBox, we save it as `custom.gembox` inside the *mrbgems*
|
||||
directory in mruby, and add the following to our *build_config.rb* file inside
|
||||
To use this example GemBox, we save it as `custom.gembox` inside the *mrbgems*
|
||||
directory in mruby, and add the following to our *build_config.rb* file inside
|
||||
the build block:
|
||||
|
||||
conf.gembox 'custom'
|
||||
@@ -60,7 +60,7 @@ the build block:
|
||||
This will cause the *custom* GemBox to be read in during the build process,
|
||||
adding *mruby-time* and *mrbgems-example* to the build.
|
||||
|
||||
If you want, you can put GemBox outside of mruby directory. In that case you must
|
||||
If you want, you can put GemBox outside of mruby directory. In that case you must
|
||||
specify absolute path like below.
|
||||
|
||||
conf.gembox "#{ENV["HOME"]}/mygemboxes/custom"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
|
||||
spec.license = 'MIT'
|
||||
spec.author = 'mruby developers'
|
||||
|
||||
|
||||
# Add compile flags
|
||||
# spec.cc.flags << ''
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
MRuby::Gem::Specification.new('c_extension_example') do |spec|
|
||||
spec.license = 'MIT'
|
||||
spec.author = 'mruby developers'
|
||||
|
||||
|
||||
# Add compile flags
|
||||
# spec.cc.flags << '-g'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
MRuby::Gem::Specification.new('ruby_extension_example') do |spec|
|
||||
spec.license = 'MIT'
|
||||
spec.author = 'mruby developers'
|
||||
|
||||
|
||||
# Add compile flags
|
||||
# spec.cc.flags << ''
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ MRuby::CrossBuild.new("Arduino Due") do |conf|
|
||||
cc.include_paths << ["#{SAM_PATH}/system/libsam", "#{SAM_PATH}/system/CMSIS/CMSIS/Include/",
|
||||
"#{SAM_PATH}/system/CMSIS/Device/ATMEL/",
|
||||
"#{SAM_PATH}/cores/arduino", "#{SAM_PATH}/libraries","#{TARGET_PATH}"]
|
||||
cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500
|
||||
-Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM
|
||||
cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500
|
||||
-Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM
|
||||
-D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due")
|
||||
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
|
||||
|
||||
@@ -57,12 +57,12 @@ MRuby::CrossBuild.new("Arduino Due") do |conf|
|
||||
conf.disable_cxx_exception
|
||||
|
||||
#gems from core
|
||||
conf.gem :core => "mruby-print"
|
||||
conf.gem :core => "mruby-print"
|
||||
conf.gem :core => "mruby-math"
|
||||
conf.gem :core => "mruby-enum-ext"
|
||||
|
||||
#light-weight regular expression
|
||||
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
|
||||
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
|
||||
|
||||
#Arduino API
|
||||
#conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
|
||||
|
||||
@@ -2,30 +2,30 @@
|
||||
# http://arduino.cc/en/ArduinoCertified/IntelGalileo
|
||||
#
|
||||
# Requires Arduino IDE for Intel Galileo
|
||||
|
||||
|
||||
MRuby::CrossBuild.new("Galileo") do |conf|
|
||||
toolchain :gcc
|
||||
|
||||
|
||||
# Mac OS X
|
||||
# Assume you renamed Arduino.app to Arduino_Galileo.app
|
||||
GALILEO_ARDUINO_PATH = '/Applications/Arduino_Galileo.app/Contents/Resources/Java'
|
||||
# GNU Linux
|
||||
#ARDUINO_GALILEO_PATH = '/opt/arduino'
|
||||
|
||||
|
||||
GALILEO_BIN_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i386-pokysdk-darwin/usr/bin/i586-poky-linux-uclibc"
|
||||
GALILEO_SYSROOT = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc"
|
||||
GALILEO_X86_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/arduino/x86"
|
||||
|
||||
|
||||
|
||||
|
||||
conf.cc do |cc|
|
||||
cc.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-gcc"
|
||||
cc.include_paths << ["#{GALILEO_X86_PATH}/cores/arduino", "#{GALILEO_X86_PATH}/variants/galileo_fab_d"]
|
||||
cc.flags = %w(-m32 -march=i586 -c -g -Os -w
|
||||
cc.flags = %w(-m32 -march=i586 -c -g -Os -w
|
||||
-ffunction-sections -fdata-sections -MMD -DARDUINO=153)
|
||||
cc.flags << "--sysroot=#{GALILEO_SYSROOT}"
|
||||
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
|
||||
end
|
||||
|
||||
|
||||
conf.cxx do |cxx|
|
||||
cxx.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++"
|
||||
cxx.include_paths = conf.cc.include_paths.dup
|
||||
@@ -35,12 +35,12 @@ MRuby::CrossBuild.new("Galileo") do |conf|
|
||||
cxx.defines = conf.cc.defines.dup
|
||||
cxx.compile_options = conf.cc.compile_options.dup
|
||||
end
|
||||
|
||||
|
||||
conf.archiver do |archiver|
|
||||
archiver.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-ar"
|
||||
archiver.archive_options = 'rcs %{outfile} %{objs}'
|
||||
end
|
||||
|
||||
|
||||
conf.linker do |linker|
|
||||
linker.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++"
|
||||
linker.flags = %w(-m32 -march=i586)
|
||||
@@ -48,13 +48,13 @@ MRuby::CrossBuild.new("Galileo") do |conf|
|
||||
linker.flags << %w(-Os -Wl,--gc-sections)
|
||||
linker.libraries = %w(m pthread)
|
||||
end
|
||||
|
||||
|
||||
#no executables
|
||||
conf.bins = []
|
||||
|
||||
|
||||
#do not build executable test
|
||||
conf.build_mrbtest_lib_only
|
||||
|
||||
|
||||
#official mrbgems
|
||||
conf.gem :core => "mruby-sprintf"
|
||||
conf.gem :core => "mruby-print"
|
||||
@@ -74,17 +74,17 @@ MRuby::CrossBuild.new("Galileo") do |conf|
|
||||
conf.gem :core => "mruby-objectspace"
|
||||
conf.gem :core => "mruby-fiber"
|
||||
conf.gem :core => "mruby-toplevel-ext"
|
||||
|
||||
|
||||
#lightweigh regular expression
|
||||
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
|
||||
|
||||
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
|
||||
|
||||
#Arduino API
|
||||
#conf.gem :github =>"kyab/mruby-arduino", :branch => "master" do |g|
|
||||
# g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Wire"
|
||||
# g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Servo"
|
||||
|
||||
|
||||
#enable unsupported Servo class
|
||||
# g.cxx.defines << "MRUBY_ARDUINO_GALILEO_ENABLE_SERVO"
|
||||
#end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -13,15 +13,15 @@ MRuby::CrossBuild.new("chipKitMax32") do |conf|
|
||||
# GNU Linux
|
||||
MPIDE_PATH = '/opt/mpide-0023-linux-20120903'
|
||||
|
||||
PIC32_PATH = "#{MPIDE_PATH}/hardware/pic32"
|
||||
PIC32_PATH = "#{MPIDE_PATH}/hardware/pic32"
|
||||
|
||||
conf.cc do |cc|
|
||||
cc.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-gcc"
|
||||
cc.include_paths << ["#{PIC32_PATH}/cores/pic32",
|
||||
"#{PIC32_PATH}/variants/Max32",
|
||||
"#{PIC32_PATH}/libraries"]
|
||||
cc.flags = %w(-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align
|
||||
-fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_
|
||||
cc.flags = %w(-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align
|
||||
-fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_
|
||||
-DMPIDEVER=0x01000202 -DMPIDE=23)
|
||||
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
|
||||
|
||||
@@ -51,16 +51,16 @@ MRuby::CrossBuild.new("chipKitMax32") do |conf|
|
||||
#no executables
|
||||
conf.bins = []
|
||||
|
||||
#do not build test executable
|
||||
#do not build test executable
|
||||
conf.build_mrbtest_lib_only
|
||||
|
||||
#gems from core
|
||||
conf.gem :core => "mruby-print"
|
||||
conf.gem :core => "mruby-print"
|
||||
conf.gem :core => "mruby-math"
|
||||
conf.gem :core => "mruby-enum-ext"
|
||||
|
||||
#light-weight regular expression
|
||||
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
|
||||
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
|
||||
|
||||
#Arduino API
|
||||
#conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
|
||||
|
||||
@@ -58,7 +58,7 @@ class Array
|
||||
ary = self.dup
|
||||
if block
|
||||
ary.uniq!(&block)
|
||||
else
|
||||
else
|
||||
ary.uniq!
|
||||
end
|
||||
ary
|
||||
@@ -370,7 +370,7 @@ class Array
|
||||
self[i] = block.call(i)
|
||||
i += 1
|
||||
end
|
||||
else
|
||||
else
|
||||
while i < len
|
||||
self[i] = arg0
|
||||
i += 1
|
||||
|
||||
@@ -19,7 +19,7 @@ end
|
||||
assert("Array#at") do
|
||||
a = [ "a", "b", "c", "d", "e" ]
|
||||
assert_equal "a", a.at(0)
|
||||
assert_equal "e", a.at(-1)
|
||||
assert_equal "e", a.at(-1)
|
||||
end
|
||||
|
||||
assert("Array#rassoc") do
|
||||
@@ -50,7 +50,7 @@ assert("Array#uniq") do
|
||||
assert_equal [1, 2, 3, 1], a
|
||||
|
||||
b = [["student","sam"], ["student","george"], ["teacher","matz"]]
|
||||
assert_equal [["student", "sam"], ["teacher", "matz"]], b.uniq { |s| s.first }
|
||||
assert_equal [["student", "sam"], ["teacher", "matz"]], b.uniq { |s| s.first }
|
||||
end
|
||||
|
||||
assert("Array#-") do
|
||||
@@ -60,7 +60,7 @@ assert("Array#-") do
|
||||
|
||||
assert_raise(TypeError) { a - c }
|
||||
assert_equal [2, 3], (a - b)
|
||||
assert_equal [1, 2, 3, 1], a
|
||||
assert_equal [1, 2, 3, 1], a
|
||||
end
|
||||
|
||||
assert("Array#|") do
|
||||
@@ -70,7 +70,7 @@ assert("Array#|") do
|
||||
|
||||
assert_raise(TypeError) { a | c }
|
||||
assert_equal [1, 2, 3, 4], (a | b)
|
||||
assert_equal [1, 2, 3, 1], a
|
||||
assert_equal [1, 2, 3, 1], a
|
||||
end
|
||||
|
||||
assert("Array#&") do
|
||||
@@ -79,8 +79,8 @@ assert("Array#&") do
|
||||
c = 1
|
||||
|
||||
assert_raise(TypeError) { a & c }
|
||||
assert_equal [1], (a & b)
|
||||
assert_equal [1, 2, 3, 1], a
|
||||
assert_equal [1], (a & b)
|
||||
assert_equal [1, 2, 3, 1], a
|
||||
end
|
||||
|
||||
assert("Array#flatten") do
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#define MIRB_READ_HISTORY(path) linenoiseHistoryLoad(history_path)
|
||||
#define MIRB_USING_HISTORY()
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ENABLE_READLINE
|
||||
#include <limits.h>
|
||||
static const char *history_file_name = ".mirb_history";
|
||||
@@ -244,7 +244,7 @@ print_cmdline(int code_block_open)
|
||||
printf("> ");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void mrb_codedump_all(mrb_state*, struct RProc*);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ while [ $# -gt 0 ]; do
|
||||
echo " switches:"
|
||||
echo " --cflags print flags passed to compiler"
|
||||
echo " --ldflags print flags passed to linker"
|
||||
echo " --libs print linked libraries"
|
||||
echo " --libs print linked libraries"
|
||||
exit 0;;
|
||||
esac
|
||||
shift
|
||||
|
||||
@@ -211,7 +211,7 @@ main(int argc, char **argv)
|
||||
cmdline = args.cmdline ? args.cmdline : "-";
|
||||
mrbc_filename(mrb, c, cmdline);
|
||||
mrb_gv_set(mrb, zero_sym, mrb_str_new_cstr(mrb, cmdline));
|
||||
}
|
||||
}
|
||||
else {
|
||||
mrbc_filename(mrb, c, "-e");
|
||||
mrb_gv_set(mrb, zero_sym, mrb_str_new_lit(mrb, "-e"));
|
||||
|
||||
@@ -92,7 +92,7 @@ module Enumerable
|
||||
end
|
||||
ary
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# call-seq:
|
||||
# enum.each_cons(n) {...} -> nil
|
||||
@@ -192,7 +192,7 @@ module Enumerable
|
||||
return to_enum :sort_by unless block_given?
|
||||
|
||||
ary = []
|
||||
orig = []
|
||||
orig = []
|
||||
self.each_with_index{|e, i|
|
||||
orig.push(e)
|
||||
ary.push([block.call(e), i])
|
||||
@@ -253,7 +253,7 @@ module Enumerable
|
||||
self.each { count += 1 }
|
||||
else
|
||||
self.each do |*val|
|
||||
count += 1 if val.__svalue == v
|
||||
count += 1 if val.__svalue == v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -108,7 +108,7 @@ assert("Enumerable#one?") do
|
||||
assert_false %w(ant bear cat).one? { |word| word.length > 4 }
|
||||
assert_false %w(ant bear cat).one? { |word| word.length < 4 }
|
||||
assert_false [nil, true, 99].one?
|
||||
assert_true [nil, true, false].one?
|
||||
assert_true [nil, true, false].one?
|
||||
end
|
||||
|
||||
assert("Enumerable#each_with_object") do
|
||||
|
||||
@@ -97,7 +97,7 @@ module Enumerable
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
def take(n)
|
||||
if n == 0
|
||||
return Lazy.new(self){raise StopIteration}
|
||||
|
||||
@@ -78,7 +78,7 @@ assert 'Enumerator#with_object arguments' do
|
||||
y << x
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
a = []
|
||||
to_three_with_string = to_three.with_object("foo")
|
||||
to_three_with_string.each do |x,string|
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* Fiber.new{...} -> obj
|
||||
*
|
||||
* Creates a fiber, whose execution is suspend until it is explicitly
|
||||
* resumed using <code>Fiber#resume</code> method.
|
||||
* resumed using <code>Fiber#resume</code> method.
|
||||
* The code running inside the fiber can give up control by calling
|
||||
* <code>Fiber.yield</code> in which case it yields control back to caller
|
||||
* (the caller of the <code>Fiber#resume</code>).
|
||||
@@ -71,7 +71,7 @@ fiber_init(mrb_state *mrb, mrb_value self)
|
||||
mrb_value blk;
|
||||
|
||||
mrb_get_args(mrb, "&", &blk);
|
||||
|
||||
|
||||
if (mrb_nil_p(blk)) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Fiber object without a block");
|
||||
}
|
||||
@@ -166,7 +166,7 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
|
||||
*b++ = *a++;
|
||||
}
|
||||
c->cibase->argc = len;
|
||||
if (c->prev->fib)
|
||||
if (c->prev->fib)
|
||||
mrb_field_write_barrier(mrb, (struct RBasic*)c->fib, (struct RBasic*)c->prev->fib);
|
||||
mrb_write_barrier(mrb, (struct RBasic*)c->fib);
|
||||
c->status = MRB_FIBER_RUNNING;
|
||||
@@ -176,7 +176,7 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
|
||||
return c->ci->proc->env->stack[0];
|
||||
}
|
||||
MARK_CONTEXT_MODIFY(c);
|
||||
if (c->prev->fib)
|
||||
if (c->prev->fib)
|
||||
mrb_field_write_barrier(mrb, (struct RBasic*)c->fib, (struct RBasic*)c->prev->fib);
|
||||
mrb_write_barrier(mrb, (struct RBasic*)c->fib);
|
||||
c->status = MRB_FIBER_RUNNING;
|
||||
@@ -332,7 +332,7 @@ fiber_current(mrb_state *mrb, mrb_value self)
|
||||
}
|
||||
return mrb_obj_value(mrb->c->fib);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mrb_mruby_fiber_gem_init(mrb_state* mrb)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ assert('Hash#merge!') do
|
||||
b = { 'cba_key' => 'XXX', 'xyz_key' => 'xyz_value' }
|
||||
|
||||
result_1 = a.merge! b
|
||||
|
||||
|
||||
a = { 'abc_key' => 'abc_value', 'cba_key' => 'cba_value' }
|
||||
result_2 = a.merge!(b) do |key, original, new|
|
||||
original
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "mruby.h"
|
||||
#include "mt19937ar.h"
|
||||
|
||||
/* Period parameters */
|
||||
/* #define N 624 */
|
||||
/* Period parameters */
|
||||
/* #define N 624 */
|
||||
#define M 397
|
||||
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
|
||||
#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
|
||||
@@ -23,8 +23,8 @@ void mrb_random_init_genrand(mt_state *t, unsigned long s)
|
||||
{
|
||||
t->mt[0]= s & 0xffffffffUL;
|
||||
for (t->mti=1; t->mti<N; t->mti++) {
|
||||
t->mt[t->mti] =
|
||||
(1812433253UL * (t->mt[t->mti-1] ^ (t->mt[t->mti-1] >> 30)) + t->mti);
|
||||
t->mt[t->mti] =
|
||||
(1812433253UL * (t->mt[t->mti-1] ^ (t->mt[t->mti-1] >> 30)) + t->mti);
|
||||
t->mt[t->mti] &= 0xffffffffUL;
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ unsigned long mrb_random_genrand_int32(mt_state *t)
|
||||
|
||||
t->mti = 0;
|
||||
}
|
||||
|
||||
|
||||
y = t->mt[t->mti++];
|
||||
|
||||
/* Tempering */
|
||||
@@ -62,7 +62,7 @@ unsigned long mrb_random_genrand_int32(mt_state *t)
|
||||
y ^= (y << 7) & 0x9d2c5680UL;
|
||||
y ^= (y << 15) & 0xefc60000UL;
|
||||
y ^= (y >> 18);
|
||||
|
||||
|
||||
t->gen.int_ = y;
|
||||
|
||||
return y;
|
||||
@@ -71,9 +71,9 @@ unsigned long mrb_random_genrand_int32(mt_state *t)
|
||||
double mrb_random_genrand_real1(mt_state *t)
|
||||
{
|
||||
mrb_random_genrand_int32(t);
|
||||
t->gen.double_ = t->gen.int_*(1.0/4294967295.0);
|
||||
t->gen.double_ = t->gen.int_*(1.0/4294967295.0);
|
||||
return t->gen.double_;
|
||||
/* divided by 2^32-1 */
|
||||
/* divided by 2^32-1 */
|
||||
}
|
||||
|
||||
#if 0 /* dead_code */
|
||||
@@ -82,8 +82,8 @@ void init_genrand(unsigned long s)
|
||||
{
|
||||
mt[0]= s & 0xffffffffUL;
|
||||
for (mti=1; mti<N; mti++) {
|
||||
mt[mti] =
|
||||
(1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
|
||||
mt[mti] =
|
||||
(1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
|
||||
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
|
||||
/* In the previous versions, MSBs of the seed affect */
|
||||
/* only MSBs of the array mt[]. */
|
||||
@@ -119,7 +119,7 @@ void init_by_array(unsigned long init_key[], int key_length)
|
||||
if (i>=N) { mt[0] = mt[N-1]; i=1; }
|
||||
}
|
||||
|
||||
mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
|
||||
mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
|
||||
}
|
||||
|
||||
/* generates a random number on [0,0xffffffff]-interval */
|
||||
@@ -148,7 +148,7 @@ unsigned long genrand_int32(void)
|
||||
|
||||
mti = 0;
|
||||
}
|
||||
|
||||
|
||||
y = mt[mti++];
|
||||
|
||||
/* Tempering */
|
||||
@@ -169,29 +169,29 @@ long genrand_int31(void)
|
||||
/* generates a random number on [0,1]-real-interval */
|
||||
double genrand_real1(void)
|
||||
{
|
||||
return genrand_int32()*(1.0/4294967295.0);
|
||||
/* divided by 2^32-1 */
|
||||
return genrand_int32()*(1.0/4294967295.0);
|
||||
/* divided by 2^32-1 */
|
||||
}
|
||||
|
||||
/* generates a random number on [0,1)-real-interval */
|
||||
double genrand_real2(void)
|
||||
{
|
||||
return genrand_int32()*(1.0/4294967296.0);
|
||||
return genrand_int32()*(1.0/4294967296.0);
|
||||
/* divided by 2^32 */
|
||||
}
|
||||
|
||||
/* generates a random number on (0,1)-real-interval */
|
||||
double genrand_real3(void)
|
||||
{
|
||||
return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
|
||||
return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
|
||||
/* divided by 2^32 */
|
||||
}
|
||||
|
||||
/* generates a random number on [0,1) with 53-bit resolution*/
|
||||
double genrand_res53(void)
|
||||
{
|
||||
unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
|
||||
return(a*67108864.0+b)*(1.0/9007199254740992.0);
|
||||
}
|
||||
double genrand_res53(void)
|
||||
{
|
||||
unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
|
||||
return(a*67108864.0+b)*(1.0/9007199254740992.0);
|
||||
}
|
||||
/* These real versions are due to Isaku Wada, 2002/01/09 added */
|
||||
#endif /* dead_code */
|
||||
|
||||
@@ -22,27 +22,27 @@ static const struct mrb_data_type mt_state_type = {
|
||||
static mrb_value mrb_random_rand(mrb_state *mrb, mrb_value self);
|
||||
static mrb_value mrb_random_srand(mrb_state *mrb, mrb_value self);
|
||||
|
||||
static void
|
||||
static void
|
||||
mt_srand(mt_state *t, unsigned long seed)
|
||||
{
|
||||
mrb_random_init_genrand(t, seed);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static unsigned long
|
||||
mt_rand(mt_state *t)
|
||||
{
|
||||
return mrb_random_genrand_int32(t);
|
||||
}
|
||||
}
|
||||
|
||||
static double
|
||||
static double
|
||||
mt_rand_real(mt_state *t)
|
||||
{
|
||||
return mrb_random_genrand_real1(t);
|
||||
}
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
static mrb_value
|
||||
mrb_random_mt_srand(mrb_state *mrb, mt_state *t, mrb_value seed)
|
||||
{
|
||||
{
|
||||
if (mrb_nil_p(seed)) {
|
||||
seed = mrb_fixnum_value(time(NULL) + mt_rand(t));
|
||||
if (mrb_fixnum(seed) < 0) {
|
||||
@@ -55,9 +55,9 @@ mrb_random_mt_srand(mrb_state *mrb, mt_state *t, mrb_value seed)
|
||||
return seed;
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
static mrb_value
|
||||
mrb_random_mt_rand(mrb_state *mrb, mt_state *t, mrb_value max)
|
||||
{
|
||||
{
|
||||
mrb_value value;
|
||||
|
||||
if (mrb_fixnum(max) == 0) {
|
||||
@@ -70,7 +70,7 @@ mrb_random_mt_rand(mrb_state *mrb, mt_state *t, mrb_value max)
|
||||
return value;
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
static mrb_value
|
||||
get_opt(mrb_state* mrb)
|
||||
{
|
||||
mrb_value arg;
|
||||
@@ -104,35 +104,35 @@ get_random_state(mrb_state *mrb)
|
||||
return DATA_GET_PTR(mrb, random_val, &mt_state_type, mt_state);
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
static mrb_value
|
||||
mrb_random_g_rand(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value random = get_random(mrb);
|
||||
return mrb_random_rand(mrb, random);
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
static mrb_value
|
||||
mrb_random_g_srand(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value random = get_random(mrb);
|
||||
return mrb_random_srand(mrb, random);
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
static mrb_value
|
||||
mrb_random_init(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value seed;
|
||||
mt_state *t;
|
||||
|
||||
|
||||
/* avoid memory leaks */
|
||||
t = (mt_state*)DATA_PTR(self);
|
||||
if (t) {
|
||||
mrb_free(mrb, t);
|
||||
}
|
||||
}
|
||||
|
||||
DATA_TYPE(self) = &mt_state_type;
|
||||
DATA_PTR(self) = NULL;
|
||||
|
||||
|
||||
t = (mt_state *)mrb_malloc(mrb, sizeof(mt_state));
|
||||
t->mti = N + 1;
|
||||
|
||||
@@ -146,13 +146,13 @@ mrb_random_init(mrb_state *mrb, mrb_value self)
|
||||
t->has_seed = TRUE;
|
||||
t->seed = mrb_fixnum(seed);
|
||||
}
|
||||
|
||||
|
||||
DATA_PTR(self) = t;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
mrb_random_rand_seed(mrb_state *mrb, mt_state *t)
|
||||
{
|
||||
if (!t->has_seed) {
|
||||
@@ -160,7 +160,7 @@ mrb_random_rand_seed(mrb_state *mrb, mt_state *t)
|
||||
}
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
static mrb_value
|
||||
mrb_random_rand(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value max;
|
||||
@@ -171,7 +171,7 @@ mrb_random_rand(mrb_state *mrb, mrb_value self)
|
||||
return mrb_random_mt_rand(mrb, t, max);
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
static mrb_value
|
||||
mrb_random_srand(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value seed;
|
||||
@@ -205,7 +205,7 @@ mrb_ary_shuffle_bang(mrb_state *mrb, mrb_value ary)
|
||||
{
|
||||
mrb_int i;
|
||||
mt_state *random = NULL;
|
||||
|
||||
|
||||
if (RARRAY_LEN(ary) > 1) {
|
||||
mrb_get_args(mrb, "|d", &random, &mt_state_type);
|
||||
|
||||
@@ -213,21 +213,21 @@ mrb_ary_shuffle_bang(mrb_state *mrb, mrb_value ary)
|
||||
random = get_random_state(mrb);
|
||||
}
|
||||
mrb_random_rand_seed(mrb, random);
|
||||
|
||||
|
||||
mrb_ary_modify(mrb, mrb_ary_ptr(ary));
|
||||
|
||||
|
||||
for (i = RARRAY_LEN(ary) - 1; i > 0; i--) {
|
||||
mrb_int j;
|
||||
mrb_value tmp;
|
||||
|
||||
|
||||
j = mrb_fixnum(mrb_random_mt_rand(mrb, random, mrb_fixnum_value(RARRAY_LEN(ary))));
|
||||
|
||||
|
||||
tmp = RARRAY_PTR(ary)[i];
|
||||
RARRAY_PTR(ary)[i] = RARRAY_PTR(ary)[j];
|
||||
RARRAY_PTR(ary)[j] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ary;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ mrb_ary_shuffle(mrb_state *mrb, mrb_value ary)
|
||||
{
|
||||
mrb_value new_ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));
|
||||
mrb_ary_shuffle_bang(mrb, new_ary);
|
||||
|
||||
|
||||
return new_ary;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ mrb_ary_sample(mrb_state *mrb, mrb_value ary)
|
||||
|
||||
mrb_get_args(mrb, "|i?d", &n, &given, &random, &mt_state_type);
|
||||
if (random == NULL) {
|
||||
random = get_random_state(mrb);
|
||||
random = get_random_state(mrb);
|
||||
}
|
||||
mrb_random_rand_seed(mrb, random);
|
||||
mt_rand(random);
|
||||
@@ -334,7 +334,7 @@ void mrb_mruby_random_gem_init(mrb_state *mrb)
|
||||
mrb_define_method(mrb, random, "initialize", mrb_random_init, MRB_ARGS_OPT(1));
|
||||
mrb_define_method(mrb, random, "rand", mrb_random_rand, MRB_ARGS_OPT(1));
|
||||
mrb_define_method(mrb, random, "srand", mrb_random_srand, MRB_ARGS_OPT(1));
|
||||
|
||||
|
||||
mrb_define_method(mrb, array, "shuffle", mrb_ary_shuffle, MRB_ARGS_OPT(1));
|
||||
mrb_define_method(mrb, array, "shuffle!", mrb_ary_shuffle_bang, MRB_ARGS_OPT(1));
|
||||
mrb_define_method(mrb, array, "sample", mrb_ary_sample, MRB_ARGS_OPT(2));
|
||||
|
||||
@@ -31,32 +31,32 @@ assert("float") do
|
||||
rand.class == Float
|
||||
end
|
||||
|
||||
assert("Array#shuffle") do
|
||||
assert("Array#shuffle") do
|
||||
ary = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
shuffled = ary.shuffle
|
||||
|
||||
|
||||
ary == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and shuffled != ary and 10.times { |x| ary.include? x }
|
||||
end
|
||||
|
||||
assert('Array#shuffle!') do
|
||||
ary = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
ary.shuffle!
|
||||
|
||||
|
||||
ary != [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and 10.times { |x| ary.include? x }
|
||||
end
|
||||
|
||||
assert("Array#shuffle(random)") do
|
||||
assert("Array#shuffle(random)") do
|
||||
assert_raise(TypeError) do
|
||||
# this will cause an exception due to the wrong argument
|
||||
[1, 2].shuffle "Not a Random instance"
|
||||
end
|
||||
|
||||
|
||||
# verify that the same seed causes the same results
|
||||
ary1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
shuffle1 = ary1.shuffle Random.new 345
|
||||
ary2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
shuffle2 = ary2.shuffle Random.new 345
|
||||
|
||||
|
||||
ary1 != shuffle1 and 10.times { |x| shuffle1.include? x } and shuffle1 == shuffle2
|
||||
end
|
||||
|
||||
@@ -65,12 +65,12 @@ assert('Array#shuffle!(random)') do
|
||||
# this will cause an exception due to the wrong argument
|
||||
[1, 2].shuffle! "Not a Random instance"
|
||||
end
|
||||
|
||||
|
||||
# verify that the same seed causes the same results
|
||||
ary1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
ary1.shuffle! Random.new 345
|
||||
ary2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
ary2.shuffle! Random.new 345
|
||||
|
||||
|
||||
ary1 != [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and 10.times { |x| ary1.include? x } and ary1 == ary2
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ assert('String#strip') do
|
||||
end
|
||||
|
||||
assert('String#lstrip') do
|
||||
s = " abc "
|
||||
s = " abc "
|
||||
s.lstrip
|
||||
"".lstrip == "" and " \t\r\n\f\v".lstrip == "" and
|
||||
"\0a\0".lstrip == "\0a\0" and
|
||||
@@ -43,7 +43,7 @@ assert('String#lstrip') do
|
||||
end
|
||||
|
||||
assert('String#rstrip') do
|
||||
s = " abc "
|
||||
s = " abc "
|
||||
s.rstrip
|
||||
"".rstrip == "" and " \t\r\n\f\v".rstrip == "" and
|
||||
"\0a\0".rstrip == "\0a" and
|
||||
@@ -122,7 +122,7 @@ end
|
||||
assert('String#partition') do
|
||||
assert_equal ["a", "x", "axa"], "axaxa".partition("x")
|
||||
assert_equal ["aaaaa", "", ""], "aaaaa".partition("x")
|
||||
assert_equal ["", "", "aaaaa"], "aaaaa".partition("")
|
||||
assert_equal ["", "", "aaaaa"], "aaaaa".partition("")
|
||||
assert_equal ["", "a", "aaaa"], "aaaaa".partition("a")
|
||||
assert_equal ["aaaa", "b", ""], "aaaab".partition("b")
|
||||
assert_equal ["", "b", "aaaa"], "baaaa".partition("b")
|
||||
@@ -132,7 +132,7 @@ end
|
||||
assert('String#rpartition') do
|
||||
assert_equal ["axa", "x", "a"], "axaxa".rpartition("x")
|
||||
assert_equal ["", "", "aaaaa"], "aaaaa".rpartition("x")
|
||||
assert_equal ["aaaaa", "", ""], "aaaaa".rpartition("")
|
||||
assert_equal ["aaaaa", "", ""], "aaaaa".rpartition("")
|
||||
assert_equal ["aaaa", "a", ""], "aaaaa".rpartition("a")
|
||||
assert_equal ["aaaa", "b", ""], "aaaab".rpartition("b")
|
||||
assert_equal ["", "b", "aaaa"], "baaaa".rpartition("b")
|
||||
|
||||
@@ -14,7 +14,7 @@ end
|
||||
assert('String#reverse', '15.2.10.5.29') do
|
||||
a = 'こんにちは世界!'
|
||||
a.reverse
|
||||
|
||||
|
||||
assert_equal 'こんにちは世界!', a
|
||||
assert_equal '!界世はちにんこ', 'こんにちは世界!'.reverse
|
||||
end
|
||||
@@ -22,7 +22,7 @@ end
|
||||
assert('String#reverse!', '15.2.10.5.30') do
|
||||
a = 'こんにちは世界!'
|
||||
a.reverse!
|
||||
|
||||
|
||||
assert_equal '!界世はちにんこ', a
|
||||
assert_equal '!界世はちにんこ', 'こんにちは世界!'.reverse!
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ assert('Toplevel#include') do
|
||||
end
|
||||
|
||||
self.include ToplevelTestModule2, ToplevelTestModule1
|
||||
|
||||
|
||||
assert_true self.class.included_modules.include?( ToplevelTestModule1 )
|
||||
assert_true self.class.included_modules.include?( ToplevelTestModule2 )
|
||||
assert_equal :foo, method_foo
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ class Hash
|
||||
}
|
||||
if hash.default_proc
|
||||
self.default_proc = hash.default_proc
|
||||
else
|
||||
else
|
||||
self.default = hash.default
|
||||
end
|
||||
self
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ MRuby.each_target do
|
||||
current_dir = File.dirname(__FILE__).relative_path_from(Dir.pwd)
|
||||
relative_from_root = File.dirname(__FILE__).relative_path_from(MRUBY_ROOT)
|
||||
current_build_dir = "#{build_dir}/#{relative_from_root}"
|
||||
|
||||
|
||||
self.libmruby << objfile("#{current_build_dir}/mrblib")
|
||||
|
||||
file objfile("#{current_build_dir}/mrblib") => "#{current_build_dir}/mrblib.c"
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ MRuby.each_target do
|
||||
current_dir = File.dirname(__FILE__).relative_path_from(Dir.pwd)
|
||||
relative_from_root = File.dirname(__FILE__).relative_path_from(MRUBY_ROOT)
|
||||
current_build_dir = "#{build_dir}/#{relative_from_root}"
|
||||
|
||||
|
||||
lex_def = "#{current_dir}/lex.def"
|
||||
objs = Dir.glob("#{current_dir}/*.c").map { |f|
|
||||
next nil if cxx_abi_enabled? and f =~ /(codegen|error|vm).c$/
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ mrb_flo_to_str(mrb_state *mrb, mrb_float flo)
|
||||
else {
|
||||
exp = 0;
|
||||
}
|
||||
|
||||
|
||||
/* preserve significands */
|
||||
if (exp < 0) {
|
||||
int i, beg = -1, end = 0;
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ mrb_print_error(mrb_state *mrb)
|
||||
{
|
||||
#ifdef ENABLE_STDIO
|
||||
mrb_value s;
|
||||
|
||||
|
||||
mrb_print_backtrace(mrb);
|
||||
s = mrb_funcall(mrb, mrb_obj_value(mrb->exc), "inspect", 0);
|
||||
if (mrb_string_p(s)) {
|
||||
|
||||
@@ -114,7 +114,7 @@ MRuby.each_target do
|
||||
if no_mrb_open_test_rbfiles.empty?
|
||||
no_mrb_open_test_rbfiles << "#{MRUBY_ROOT}/test/no_mrb_open_test_dummy.rb"
|
||||
end
|
||||
|
||||
|
||||
no_mrb_open_test_lib = no_mrb_open_test.ext(exts.object)
|
||||
file no_mrb_open_test_lib => "#{no_mrb_open_test}.c"
|
||||
file "#{no_mrb_open_test}.c" => no_mrb_open_test_rbfiles do |t|
|
||||
|
||||
@@ -143,9 +143,9 @@ module MRuby
|
||||
def define_rules
|
||||
compilers.each do |compiler|
|
||||
if respond_to?(:enable_gems?) && enable_gems?
|
||||
compiler.defines -= %w(DISABLE_GEMS)
|
||||
compiler.defines -= %w(DISABLE_GEMS)
|
||||
else
|
||||
compiler.defines += %w(DISABLE_GEMS)
|
||||
compiler.defines += %w(DISABLE_GEMS)
|
||||
end
|
||||
compiler.define_rules build_dir, File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||
end
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ class String
|
||||
def relative_path
|
||||
relative_path_from(Dir.pwd)
|
||||
end
|
||||
|
||||
|
||||
# Compatible with 1.9 on 1.8
|
||||
def %(params)
|
||||
if params.is_a?(Hash)
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ def assert_equal(arg1, arg2 = nil, arg3 = nil)
|
||||
else
|
||||
exp, act, msg = arg1, arg2, arg3
|
||||
end
|
||||
|
||||
|
||||
msg = "Expected to be equal" unless msg
|
||||
diff = assertion_diff(exp, act)
|
||||
assert_true(exp == act, msg, diff)
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ t_printstr(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
char *s;
|
||||
int len;
|
||||
|
||||
|
||||
if (mrb_string_p(obj)) {
|
||||
s = RSTRING_PTR(obj);
|
||||
len = RSTRING_LEN(obj);
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ assert('Hash#replace', '15.2.13.4.23') do
|
||||
b = {}
|
||||
b.replace(a)
|
||||
assert_equal(42, b[1])
|
||||
|
||||
|
||||
a = Hash.new{|h,x| x}
|
||||
b.replace(a)
|
||||
assert_equal(127, b[127])
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ assert('The undef statement', '13.3.7 a) 4)') do
|
||||
assert_true(existing_method_e, 'Method should be defined')
|
||||
assert_true(existing_method_f, 'Method should be defined')
|
||||
|
||||
# undefine in all possible ways and check that method
|
||||
# undefine in all possible ways and check that method
|
||||
# is undefined
|
||||
|
||||
undef existing_method_a
|
||||
|
||||
+6
-6
@@ -485,19 +485,19 @@ end
|
||||
assert('Issue 1467') do
|
||||
module M1
|
||||
def initialize()
|
||||
super()
|
||||
super()
|
||||
end
|
||||
end
|
||||
|
||||
class C1
|
||||
include M1
|
||||
def initialize()
|
||||
super()
|
||||
class C1
|
||||
include M1
|
||||
def initialize()
|
||||
super()
|
||||
end
|
||||
end
|
||||
|
||||
class C2
|
||||
include M1
|
||||
include M1
|
||||
end
|
||||
|
||||
C1.new
|
||||
|
||||
Reference in New Issue
Block a user