Skip to content

Commit

Permalink
Remove the other String functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Oct 26, 2018
1 parent 1a2dcc2 commit 671ca5d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 48 deletions.
6 changes: 0 additions & 6 deletions expreduce/atoms/ex_complex.go
Expand Up @@ -22,12 +22,6 @@ func (cmplx *Complex) StringForm(p expreduceapi.ToStringParams) string {
return fmt.Sprintf("(%v + %v*I)", cmplx.Re.StringForm(p), cmplx.Im.StringForm(p))
}

func (cmplx *Complex) String(esi expreduceapi.EvalStateInterface) string {
context, contextPath := defaultStringFormArgs()
return cmplx.StringForm(expreduceapi.ToStringParams{
Form: "InputForm", Context: context, ContextPath: contextPath, Esi: esi})
}

func (cmplx *Complex) IsEqual(other expreduceapi.Ex) string {
otherConv, otherIsComplex := other.(*Complex)
if !otherIsComplex {
Expand Down
6 changes: 0 additions & 6 deletions expreduce/atoms/ex_expression.go
Expand Up @@ -130,12 +130,6 @@ func (thisExpr *Expression) StringForm(params expreduceapi.ToStringParams) strin
return buffer.String()
}

func (thisExpr *Expression) String(esi expreduceapi.EvalStateInterface) string {
context, contextPath := defaultStringFormArgs()
return thisExpr.StringForm(expreduceapi.ToStringParams{
Form: "InputForm", Context: context, ContextPath: contextPath, Esi: esi})
}

func (thisExpr *Expression) IsEqual(otherEx expreduceapi.Ex) string {
other, ok := otherEx.(*Expression)
if !ok {
Expand Down
5 changes: 0 additions & 5 deletions expreduce/atoms/ex_integer.go
Expand Up @@ -31,11 +31,6 @@ func (thisInt *Integer) StringForm(params expreduceapi.ToStringParams) string {
return fmt.Sprintf("%d", thisInt.Val)
}

func (thisInt *Integer) String(esi expreduceapi.EvalStateInterface) string {
context, contextPath := defaultStringFormArgs()
return thisInt.StringForm(expreduceapi.ToStringParams{Form: "InputForm", Context: context, ContextPath: contextPath, Esi: esi})
}

func (thisInt *Integer) IsEqual(other expreduceapi.Ex) string {
otherConv, ok := other.(*Integer)
if !ok {
Expand Down
5 changes: 0 additions & 5 deletions expreduce/atoms/ex_rational.go
Expand Up @@ -28,11 +28,6 @@ func (thisRational *Rational) StringForm(params expreduceapi.ToStringParams) str
return fmt.Sprintf("%d/%d", thisRational.Num, thisRational.Den)
}

func (thisRational *Rational) String(esi expreduceapi.EvalStateInterface) string {
context, contextPath := defaultStringFormArgs()
return thisRational.StringForm(expreduceapi.ToStringParams{Form: "InputForm", Context: context, ContextPath: contextPath, Esi: esi})
}

func (thisRational *Rational) IsEqual(other expreduceapi.Ex) string {
otherConv, otherIsRational := other.(*Rational)
if !otherIsRational {
Expand Down
5 changes: 0 additions & 5 deletions expreduce/atoms/ex_real.go
Expand Up @@ -42,11 +42,6 @@ func (flt *Flt) StringForm(params expreduceapi.ToStringParams) string {
return buffer.String()
}

func (flt *Flt) String(esi expreduceapi.EvalStateInterface) string {
context, contextPath := defaultStringFormArgs()
return flt.StringForm(expreduceapi.ToStringParams{Form: "InputForm", Context: context, ContextPath: contextPath, Esi: esi})
}

func (flt *Flt) IsEqual(other expreduceapi.Ex) string {
otherConv, ok := other.(*Flt)
if !ok {
Expand Down
5 changes: 0 additions & 5 deletions expreduce/atoms/ex_string.go
Expand Up @@ -20,11 +20,6 @@ func (str *String) StringForm(params expreduceapi.ToStringParams) string {
return fmt.Sprintf("\"%v\"", str.Val)
}

func (str *String) String(esi expreduceapi.EvalStateInterface) string {
context, contextPath := defaultStringFormArgs()
return str.StringForm(expreduceapi.ToStringParams{Form: "InputForm", Context: context, ContextPath: contextPath, Esi: esi})
}

func (str *String) IsEqual(other expreduceapi.Ex) string {
otherConv, ok := other.(*String)
if !ok {
Expand Down
5 changes: 0 additions & 5 deletions expreduce/atoms/ex_symbol.go
Expand Up @@ -50,11 +50,6 @@ func (sym *Symbol) StringForm(params expreduceapi.ToStringParams) string {
return formatSymName(sym.Name, params)
}

func (sym *Symbol) String(esi expreduceapi.EvalStateInterface) string {
context, contextPath := defaultStringFormArgs()
return sym.StringForm(expreduceapi.ToStringParams{Form: "InputForm", Context: context, ContextPath: contextPath, Esi: esi})
}

func (sym *Symbol) IsEqual(other expreduceapi.Ex) string {
otherConv, ok := other.(*Symbol)
if !ok {
Expand Down
23 changes: 12 additions & 11 deletions expreduce/cas_test.go
Expand Up @@ -114,6 +114,7 @@ func TestLowLevel(t *testing.T) {
fmt.Println("Testing low-level structs")

es := NewEvalState()
stringParams := ActualStringFormArgsFull("InputForm", es)

lhs := atoms.NewExpression([]expreduceapi.Ex{
atoms.NewSymbol("System`Power"),
Expand Down Expand Up @@ -147,9 +148,9 @@ func TestLowLevel(t *testing.T) {

// Test basic float functionality
var f *atoms.Flt = atoms.NewReal(big.NewFloat(5.5))
assert.Equal(t, "5.5", f.String(es))
assert.Equal(t, "5.5", f.StringForm(stringParams))
es.Eval(f)
assert.Equal(t, "5.5", f.String(es))
assert.Equal(t, "5.5", f.StringForm(stringParams))

// Test nested addition functionality
var a = atoms.NewExpression([]expreduceapi.Ex{
Expand All @@ -173,14 +174,13 @@ func TestLowLevel(t *testing.T) {

// Test evaluation
newa := es.Eval(a)
stringParams := ActualStringFormArgsFull("InputForm", es)
assert.Equal(t, "87.5", newa.StringForm(stringParams))

// Test basic Symbol functionality
var v *atoms.Symbol = atoms.NewSymbol("System`x")
assert.Equal(t, "x", v.String(es))
assert.Equal(t, "x", v.StringForm(stringParams))
es.Eval(v)
assert.Equal(t, "x", v.String(es))
assert.Equal(t, "x", v.StringForm(stringParams))

casAssertSame(t, es, "(a + b + c + d + e + f)", "a + b + c +d +e +f")
casAssertSame(t, es, "(a*b*c*d*e*f)", "a * b * c *d *e *f")
Expand All @@ -202,6 +202,7 @@ func TestDeepCopy(t *testing.T) {

// So that we can print the values. Not very necessary.
es := NewEvalState()
stringParams := ActualStringFormArgsFull("InputForm", es)

// Test deepcopy
var t1 = atoms.NewSymbol("System`x")
Expand All @@ -219,14 +220,14 @@ func TestDeepCopy(t *testing.T) {
var t4 = atoms.NewReal(big.NewFloat(2))
t5 := *t4
t6 := t4.DeepCopy().(*atoms.Flt)
assert.Equal(t, "2.", t4.String(es))
assert.Equal(t, "2.", t5.String(es))
assert.Equal(t, "2.", t6.String(es))
assert.Equal(t, "2.", t4.StringForm(stringParams))
assert.Equal(t, "2.", t5.StringForm(stringParams))
assert.Equal(t, "2.", t6.StringForm(stringParams))
t5.Val.Add(t5.Val, big.NewFloat(2))
t6.Val.Add(t6.Val, big.NewFloat(3))
assert.Equal(t, "4.", t4.String(es)) // Because we used the wrong copy method
assert.Equal(t, "4.", t5.String(es))
assert.Equal(t, "5.", t6.String(es))
assert.Equal(t, "4.", t4.StringForm(stringParams)) // Because we used the wrong copy method
assert.Equal(t, "4.", t5.StringForm(stringParams))
assert.Equal(t, "5.", t6.StringForm(stringParams))
}

func TestConcurrency(t *testing.T) {
Expand Down

0 comments on commit 671ca5d

Please sign in to comment.