Skip to content

version 0.1.9

Compare
Choose a tag to compare
@st0012 st0012 released this 03 Apr 16:22
· 669 commits to master since this release

Features

Builtin Test Framework

Now you can use built-in test framework: spec to write specs for Goby program! For example:

require "spec"

Spec.describe Spec do
  describe "comparison" do
    describe "#to eq" do
      it "compares if two values are equal" do
        expect(1).to eq(1)
      end
    end

    describe "#not_to eq" do
      it "compares if two values are not equal" do
        expect(1).not_to eq(2)
      end
    end
  end

  describe "indentation" do
    it "indents four spaces" do
    end
    describe "nest another level" do
      it "indents six spaces" do
      end
    end
  end
end

And to run the spec, use goby test FILE_OR_DIRECTORY_PATH.
Then it will run the spec and print the output like:

Spec
  comparison
    #to eq
      it "compares if two values are equal"
    #not_to eq
      it "compares if two values are not equal"
  indentation
    it "indents four spaces"
    nest another level
      it "indents six spaces"

Support Descending Range

Thanks to @ear7h, this is a feature that does not exist in Ruby but now in Goby!
Take the following code as an example:

sum = 0
(2..-9).step(3) do |i|
  sum = sum + i
end
puts(sum)

In Ruby it returns 0 cause it does not support descending range.
But in Goby it will return -10 😁

New APIs

Fixes (thanks to @shes50103)