Skip to content

Commit

Permalink
Merge pull request #266 from Eclalang/issue-#228-refactor-tests
Browse files Browse the repository at this point in the history
Issue #228 refactor tests
  • Loading branch information
tot0p authored Feb 26, 2024
2 parents 5dabc64 + 4612b22 commit 63473b9
Show file tree
Hide file tree
Showing 5 changed files with 1,602 additions and 205 deletions.
4 changes: 2 additions & 2 deletions interpreter/eclaType/bool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ func TestOrBoolChar(t *testing.T) {

func TestAddBoolString(t *testing.T) {
t1 := NewBool("true")
t2 := NewString("Hello")
t2, _ := NewString("Hello")
actual, err := t1.Add(t2)
if err != nil {
t.Errorf("Error: %s", err)
}
expected := NewString("trueHello")
expected, _ := NewString("trueHello")
if actual != expected {
t.Errorf("Expected %s, got %s", expected, actual)
}
Expand Down
18 changes: 6 additions & 12 deletions interpreter/eclaType/char_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,25 +914,19 @@ func TestCharAppendChar(t *testing.T) {
t1 := Char('A')
t2 := Char('B')

result, err := t1.Append(t2)
if err != nil {
t.Error(err)
}
if result.GetValue() != String("AB") {
t.Error("Expected AB, got ", result)
_, err := t1.Append(t2)
if err == nil {
t.Error("Expected error")
}
}

func TestCharAppendString(t *testing.T) {
t1 := Char('A')
t2 := String("BC")

result, err := t1.Append(t2)
if err != nil {
t.Error(err)
}
if result.GetValue() != String("ABC") {
t.Error("Expected ABC, got ", result)
_, err := t1.Append(t2)
if err == nil {
t.Error("Expected error")
}
}

Expand Down
8 changes: 4 additions & 4 deletions interpreter/eclaType/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
// Useless tests for code coverage purpose
func TestGetValue(t *testing.T) {
f := NewFunction("test", nil, nil, nil)
if f.GetValue() != nil {
t.Errorf("Expected nil, got %v", f.GetValue())
if f.GetValue() == nil {
t.Error("Expected not nil, got nil")
}
}

Expand All @@ -36,8 +36,8 @@ func TestGetString(t *testing.T) {

func TestGetType(t *testing.T) {
f := NewFunction("test", nil, nil, nil)
if f.GetType() != "function" {
t.Errorf("Expected function, got %v", f.GetType())
if f.GetType() != "function()" {
t.Errorf("Expected function(), got %v", f.GetType())
}
}

Expand Down
Loading

0 comments on commit 63473b9

Please sign in to comment.