Test bin

From Erights

(Difference between revisions)
Jump to: navigation, search
(Expansion of bare try: new test case)
 
(2 intermediate revisions not shown)
Line 1: Line 1:
This page is for E implementation conformance tests for which a more specific location has not ''yet'' been found.
This page is for E implementation conformance tests for which a more specific location has not ''yet'' been found.
 +
 +
===How [[User:Kevin Reid]] thinks doc-comments ought to work===
 +
 +
(1 outside space is dropped, function obj doc goes on the method) {{XXX|add multiline doc tests, w roundtrip}}
 +
 +
? /** foo */ def x {}
 +
# value: <x>
 +
 +
? x.__getAllegedType().getDocComment()
 +
# value: "foo"
 +
 +
? /** foo */ def y() :void {}
 +
# value: <y>
 +
 +
? y.__getAllegedType().getDocComment()
 +
# value: ""
 +
 +
? y.__getAllegedType().getMessageTypes()["run/0"].getDocComment()
 +
# value: "foo"
 +
 +
===Trailing commas===
 +
 +
Trailing commas should be consistently accepted everywhere (aren't in map-patterns):
 +
? __identityFunc(1,)
 +
# value: 1
 +
 +
? [1,]
 +
# value: [1]
 +
 +
? [1 => 2,]
 +
# value: [1 => 2]
 +
 +
? [null, true, false][1,]
 +
# value: true
 +
 +
? def [a,] := [1]
 +
# value: [1]
 +
 +
? def foo(a,) :void {}
 +
# value: <foo>
 +
 +
 +
===Expansion of multiple try-catch===
 +
 +
? try { throw("oops") } catch ==1 {}
 +
# problem: oops
 +
 +
? try { throw("oops") } catch ==1 {} catch ==2 {}
 +
# problem: oops
 +
That is, none of the patterns matching should be equivalent to a single catch not matching (Fails in [[EoJ]] 0.9.1b)
 +
 +
===Expansion of bare try===
 +
 +
? def x := 1; try { def x := 2 }; x
 +
# value: 1
 +
 +
General <code>try</code> should expand to a [[HideExpr]] for the sake of scoping if there are no clauses. (Currently fails in [[E-on-CL]].)
===Expansion of bind===
===Expansion of bind===
Line 74: Line 131:
  ? E.toString(help(/** FOO */ def _{})).indexOf("FOO") != -1
  ? E.toString(help(/** FOO */ def _{})).indexOf("FOO") != -1
  # value: true
  # value: true
 +
 +
===Behavior of __getAllegedType on objects with non-general matchers===
 +
{{XXX|write some explanation with this}}
 +
 +
? def _ {}.__getAllegedType()
 +
# value: _
 +
 +
? def _ { match _ {} }.__getAllegedType()
 +
# value: _
 +
 +
? def _ { match [] {} }.__getAllegedType()
 +
# value: _
 +
 +
? require.__getAllegedType()
 +
# value: require0
 +
 +
===Processing __N should be idempotent===
 +
 +
? def foos := ["a", "b"]
 +
 +
? e`def [foo__1, foo__2] := foos`
 +
# value: e`def [foo__1, foo__2] := foos`
 +
 +
? e__quasiParser(e`def [foo__1, foo__2] := foos`.asText()) \
 +
>            =~ e`def [foo__1, foo__2] := foos`
 +
# value: true
 +
 +
? def [foo__1, foo__2] := foos; null
 +
? [=> foo__1, => foo__2]
 +
# value: ["foo__1" => "a", "foo__2" => "b"]
 +
 +
? meta.getState()["&foo__1"].getValue()
 +
# value: "a"
==Regression tests==
==Regression tests==
-
This used to hang on [[E-on-Java]]
+
===This used to hang on [[E-on-Java]]===
  ? def T := nullOk[Tuple[any, T]]
  ? def T := nullOk[Tuple[any, T]]
  # value: nullOk[Tuple[any, <***CYCLE***>]]
  # value: nullOk[Tuple[any, <***CYCLE***>]]
-
These used to reveal pointers on [[E-on-Java]]
+
===These used to reveal pointers on [[E-on-Java]]===
  ? [].asMap()[<import:java.lang.makeObject>()]
  ? [].asMap()[<import:java.lang.makeObject>()]
  # problem: <IndexOutOfBoundsException: <an Object> not found>
  # problem: <IndexOutOfBoundsException: <an Object> not found>
Line 88: Line 178:
  # problem: <NoSuchMethodException: <a Double>.random/0>
  # problem: <NoSuchMethodException: <a Double>.random/0>
-
???
+
===???===
  ? def l := [].diverge(char)
  ? def l := [].diverge(char)
  # value: [].diverge()
  # value: [].diverge()
Line 97: Line 187:
  # value: ['a', 'b', 'c'].diverge()
  # value: ['a', 'b', 'c'].diverge()
-
This used to fail to be rejected in [[E-on-Java]]
+
===This used to fail to be rejected in [[E-on-Java]]===
  ? { x + 1; def x := 2 }
  ? { x + 1; def x := 2 }
  # problem: Failed: Undefined variable: x
  # problem: Failed: Undefined variable: x
Line 107: Line 197:
   # value: 2
   # value: 2
   # value: [485, 2]
   # value: [485, 2]
 +
 +
===Miranda messages should not expose Java typed names===
 +
 +
? def obj {
 +
>  to __getAllegedType() :any { return null.__getAllegedType() }
 +
> }
 +
# value: <obj>
 +
 +
? obj.__getAllegedType()
 +
# value: void
 +
 +
? [obj."__getAllegedType()"()]
 +
# problem: <NoSuchMethodException: <an obj>.__getAllegedType()/0>
 +
[[Category:E specification]]
[[Category:E specification]]

Latest revision as of 01:48, 10 June 2013

This page is for E implementation conformance tests for which a more specific location has not yet been found.

Contents

How User:Kevin Reid thinks doc-comments ought to work

(1 outside space is dropped, function obj doc goes on the method) XXX add multiline doc tests, w roundtrip

? /** foo */ def x {}
# value: <x>

? x.__getAllegedType().getDocComment()
# value: "foo"

? /** foo */ def y() :void {}
# value: <y>

? y.__getAllegedType().getDocComment()
# value: ""

? y.__getAllegedType().getMessageTypes()["run/0"].getDocComment()
# value: "foo"

Trailing commas

Trailing commas should be consistently accepted everywhere (aren't in map-patterns):

? __identityFunc(1,)
# value: 1

? [1,]
# value: [1]

? [1 => 2,]
# value: [1 => 2]

? [null, true, false][1,]
# value: true

? def [a,] := [1]
# value: [1]

? def foo(a,) :void {}
# value: <foo>

Expansion of multiple try-catch

? try { throw("oops") } catch ==1 {}
# problem: oops

? try { throw("oops") } catch ==1 {} catch ==2 {}
# problem: oops

That is, none of the patterns matching should be equivalent to a single catch not matching (Fails in EoJ 0.9.1b)

Expansion of bare try

? def x := 1; try { def x := 2 }; x
# value: 1

General try should expand to a HideExpr for the sake of scoping if there are no clauses. (Currently fails in E-on-CL.)

Expansion of bind

? def x
# value: <Resolver>

? bind x {}
# value: <x>

? x.__getAllegedType().getFQName()
# value: "__main$x"

Expansion of map pattern

? def a := "43"
# value: "43"

? def b :int := a
# problem: <ClassCastException: String doesn't coerce to an int>

? def [b :int] := [a]
# problem: <ClassCastException: String doesn't coerce to an int>

? def ["" => b :int] := ["" => a]
# problem: <ClassCastException: String doesn't coerce to an int>

? def ["x" => _] := ["" => a]
# problem: x not found

Serialization

? pragma.syntax("0.9")
> pragma.enable("accumulator")

? def makeSurgeon := <elib:serial.makeSurgeon>
# value: <makeSurgeon>

? def surgeons := ["default" => makeSurgeon(), "src" => makeSurgeon.withSrcKit(null)]
# value: ["default" => <surgeon>, "src" => <readOnlySurgeon>]

? def check(x, ignore) {
>   def diffs := accum [].asMap() for k => surgeon in surgeons { _.with(k,
>     def y := surgeon.unserialize(surgeon.serialize(x))
>     accum [] for check ? (!ignore.contains(check)) => r ? (!r) in [
>       "same"  => x == y,
>       "equiv" => !x.__respondsTo("compareTo",1) || x <=> y,
>       "print" => E.toString(x) == E.toString(y)
>     ] { _.with([check, x, y]) }
>   )}
>   return accum [].asMap() for k => v ? (v !~ []) in diffs { _.with(k, v) }
> }
# value: <check>

? check(1, [])
# value: [].asMap()

? check([1,2,3], [])
# value: [].asMap()

? check(def x := [1,2,x], [])
# value: [].asMap()

? check(Guard, [])
# value: [].asMap()

? check(78452960457820936578390758342950673284590431267589324057832946723148963275893465783049856783294507632894506732158912365478567145683415063127849561839450768239032675890432675843294067538490576382590432764589320457832940732849507324893076849051326758903426758903265748329405678329056732895032764853290576438259063278590267589023157689023456784321905632748950634278590342675893214056732841095673214850934726589032467583904576823904561758463859340758329067430642891467389027548790365783567438567473287237458763289478945137536498671236478658920786905234876435187903524783452608079342580796345218076953410876913458079634512087963451208796345017890493578108793452107893451289073452178960345179802879345178693451025734689012768059341278695134278906543210453780216978690543214532786091453782619054386719023452187690134528076931248570691578034629132076845932145768032104657834521780690786934512673845120978603459123456712809341572680931457086293457806219, [])
# value: [].asMap()

? check([].diverge(), ["same"])
# value: [].asMap()

???

? E.toString(help(/** FOO */ def _{})).indexOf("FOO") != -1
# value: true

Behavior of __getAllegedType on objects with non-general matchers

XXX write some explanation with this

? def _ {}.__getAllegedType()
# value: _

? def _ { match _ {} }.__getAllegedType()
# value: _

? def _ { match [] {} }.__getAllegedType()
# value: _

? require.__getAllegedType()
# value: require0

Processing __N should be idempotent

? def foos := ["a", "b"]

? e`def [foo__1, foo__2] := foos`
# value: e`def [foo__1, foo__2] := foos`

? e__quasiParser(e`def [foo__1, foo__2] := foos`.asText()) \
>             =~ e`def [foo__1, foo__2] := foos`
# value: true

? def [foo__1, foo__2] := foos; null
? [=> foo__1, => foo__2]
# value: ["foo__1" => "a", "foo__2" => "b"]

? meta.getState()["&foo__1"].getValue()
# value: "a"

Regression tests

This used to hang on E-on-Java

? def T := nullOk[Tuple[any, T]]
# value: nullOk[Tuple[any, <***CYCLE***>]]

These used to reveal pointers on E-on-Java

? [].asMap()[<import:java.lang.makeObject>()]
# problem: <IndexOutOfBoundsException: <an Object> not found>

? 1.0.random()
# problem: <NoSuchMethodException: <a Double>.random/0>

???

? def l := [].diverge(char)
# value: [].diverge()

? l.append(['a', 'b', 'c'])

? l
# value: ['a', 'b', 'c'].diverge()

This used to fail to be rejected in E-on-Java

? { x + 1; def x := 2 }
# problem: Failed: Undefined variable: x

? {[x + 1, def x := 2]}
# problem: Failed: Undefined variable: x

As of 0.8.30d, the results of these were:

  # value: 2
  # value: [485, 2]

Miranda messages should not expose Java typed names

? def obj {
>   to __getAllegedType() :any { return null.__getAllegedType() }
> }
# value: <obj>

? obj.__getAllegedType()
# value: void

? [obj."__getAllegedType()"()]
# problem: <NoSuchMethodException: <an obj>.__getAllegedType()/0>
Personal tools
more tools