File tree Expand file tree Collapse file tree 6 files changed +61
-11
lines changed
Expand file tree Collapse file tree 6 files changed +61
-11
lines changed Original file line number Diff line number Diff line change 1+ # v0.15.2-dev
2+ * Bug fixes
3+ * Fixed protocol implementations for Integer and Float which where not recognized
4+ * Fixed calling properties on non-objects
5+
16# v0.15.1
27* Bug fixes
38 * Fixed View module so that an element can have multiple elements within
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ defmodule ElixirScript.Mixfile do
44 def project do
55 [
66 app: :elixir_script ,
7- version: "0.15.1 " ,
7+ version: "0.15.2-dev " ,
88 elixir: "~> 1.0" ,
99 escript: escript_config ,
1010 deps: deps ,
Original file line number Diff line number Diff line change @@ -6,12 +6,22 @@ import Protocol from './protocol';
66function call_property ( item , property ) {
77 let prop = null ;
88
9- if ( property in item ) {
9+ if ( typeof item === "number" || typeof item === "symbol" || typeof item === "boolean" || typeof item === "string" ) {
10+ if ( item [ property ] !== undefined ) {
1011 prop = property ;
11- } else if ( Symbol . for ( property ) in item ) {
12- prop = Symbol . for ( property ) ;
13- } else {
14- throw new Error ( `Property ${ property } not found in ${ item } ` ) ;
12+ } else if ( item [ Symbol . for ( property ) ] !== undefined ) {
13+ prop = Symbol . for ( property ) ;
14+ }
15+ } else {
16+ if ( property in item ) {
17+ prop = property ;
18+ } else if ( Symbol . for ( property ) in item ) {
19+ prop = Symbol . for ( property ) ;
20+ }
21+ }
22+
23+ if ( prop === null ) {
24+ throw new Error ( `Property ${ property } not found in ${ item } ` ) ;
1525 }
1626
1727 if ( item [ prop ] instanceof Function ) {
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ class Protocol{
4545 }
4646
4747 hasImplementation ( thing ) {
48+ if ( thing === Integer || thing === Float ) {
49+ return this . registry . has ( thing ) ;
50+ }
51+
4852 return this . registry . has ( thing . constructor ) ;
4953 }
5054}
Original file line number Diff line number Diff line change 1+ var Functions = require ( '../../lib/core' ) . Functions ;
2+ var expect = require ( 'chai' ) . expect ;
3+
4+ describe ( 'Functions' , function ( ) {
5+
6+ it ( 'call_property' , function ( ) {
7+ expect ( Functions . call_property ( 1 , "toString" ) ) . to . equal ( "1" ) ;
8+ expect ( Functions . call_property ( [ ] , "toString" ) ) . to . equal ( "" ) ;
9+ expect ( Functions . call_property ( [ ] , "length" ) ) . to . equal ( 0 ) ;
10+ expect ( Functions . call_property ( "" , "toString" ) ) . to . equal ( "" ) ;
11+ expect ( Functions . call_property ( "" , "length" ) ) . to . equal ( 0 ) ;
12+ expect ( Functions . call_property ( Symbol ( "test" ) , "toString" ) ) . to . equal ( "Symbol(test)" ) ;
13+ expect ( Functions . call_property ( { completed : false } , "completed" ) ) . to . equal ( false ) ;
14+ expect ( Functions . call_property ( { id : 0 } , "id" ) ) . to . equal ( 0 ) ;
15+ } ) ;
16+
17+ } ) ;
You can’t perform that action at this time.
0 commit comments