Changeset 6032

Show
Ignore:
Timestamp:
08/03/05 16:31:44 (3 years ago)
Author:
iblech
svk:copy_cache_prev:
8154
Message:

* Usual svn props.
* PIL2JS:

  • PIL2JS.js: Fixed display of native JS exceptions.
  • New Prelude::JS::Context: Added stub &scalar and &list.
  • New Prelude::JS::Math: Added &pi, &atan (with one and two args), &sin, &cos, &tan, &asin, and &acos.
  • Prelude::JS::Array: Added &reverse (but doesn't use context yet).

* t/builtins/math/trig.t: Added TODO feature tests for &asin and &acos.

Files:
2 added
6 modified

Legend:

Unmodified
Added
Removed
  • debian/pugs-modules.install

    • Property svn:mime-type set to text/plain; charset=UTF-8
    • Property svn:eol-style set to native
  • perl5/PIL2JS/lib/PIL/PApp.pm

    r5990 r6032  
    7575  $native++ if 
    7676    defined $obj and $obj =~ /^[\&\$\@\+\%\:]\*?JS::/; 
     77  $native++ if 
     78    defined $obj and $subname =~ /^&\*?JS::/; 
    7779 
    7880  # The sub is a reference? ==> We can't know at compile-time. 
  • perl5/PIL2JS/lib6/Prelude/JS.pm

    r6000 r6032  
    2424use Prelude::JS::Hash; 
    2525use Prelude::JS::Array; 
     26use Prelude::JS::Context; 
     27use Prelude::JS::Math; 
    2628 
    2729method JS::Root::undefine($a is rw:) { 
  • perl5/PIL2JS/lib6/Prelude/JS/Array.pm

    r6024 r6032  
    164164  $sum += +$_ for @vals; 
    165165  $sum; 
     166} 
     167 
     168method reverse(*@things is copy:) { 
     169  # Hack, should of course use context info, but that's not here yet. 
     170  if @things == 1 { 
     171    JS::inline('(function (str) { return str.split("").reverse().join("") })')(@things[0]); 
     172  } else { 
     173    JS::inline('new PIL2JS.Box.Constant(function (args) { 
     174      var arr = args[1].FETCH(); 
     175      arr.reverse(); 
     176      return new PIL2JS.Box.Constant(arr); 
     177    })')(@things); 
     178  } 
    166179} 
    167180 
  • perl5/PIL2JS/libjs/PIL2JS.js

    r6025 r6032  
    635635  _26main_3a_3asay.FETCH()([ 
    636636    PIL2JS.Context.Void, 
    637     _26main_3a_3aprefix_3a_7e.FETCH()([PIL2JS.Context.ItemAny, err.pil2js_orig_msg]) 
     637    _26main_3a_3aprefix_3a_7e.FETCH()([ 
     638      PIL2JS.Context.ItemAny, 
     639      err.pil2js_orig_msg 
     640        ? err.pil2js_orig_msg 
     641        : new PIL2JS.Box.Constant(err.toString()) 
     642    ]) 
    638643  ]); 
    639644}; 
  • t/builtins/math/trig.t

    r3702 r6032  
    44use Test; 
    55 
    6 plan 45; 
    7 # force_todo 2 .. 8, 12 .. 20; 
     6plan 51; 
    87 
    98=head1 DESCRIPTION 
     
    9089ok(approx(tan(7/4*$PI), -1)); 
    9190ok(approx(tan(8/4*$PI), 0)); 
     91 
     92# asin 
     93ok(approx(try{asin(0)},            0)); 
     94ok(approx(try{asin(1/2*sqrt(2))},  1/4*$PI), :todo<feature>); 
     95ok(approx(try{asin(1)},            2/4*$PI), :todo<feature>); 
     96 
     97# acos 
     98ok(approx(try{acos(0)},            2/4*$PI), :todo<feature>); 
     99ok(approx(try{acos(1/2*sqrt(2))},  1/4*$PI), :todo<feature>); 
     100ok(approx(try{acos(1)},            0/4*$PI));