mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-12 08:40:20 +02:00
Fix ECMAScript object creation.
* module/language/ecmascript/compile-tree-il.scm (compile-tree-il): generate correct tree-il for construction of new objects. * test-suite/tests/ecmascript.test (ecompile): Add pattern with EXPECTED omitted. ("compiler"): test whether we generate new objects correctly. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
9dfcd9e2d6
commit
8891bd1b16
2 changed files with 18 additions and 11 deletions
|
@ -366,8 +366,8 @@
|
||||||
`(apply ,(@implv new-array)
|
`(apply ,(@implv new-array)
|
||||||
,@(map (lambda (x) (comp x e)) args)))
|
,@(map (lambda (x) (comp x e)) args)))
|
||||||
((object . ,args)
|
((object . ,args)
|
||||||
(@impl new-object
|
`(apply (@ (language ecmascript impl) new-object)
|
||||||
(map (lambda (x)
|
,@(map (lambda (x)
|
||||||
(pmatch x
|
(pmatch x
|
||||||
((,prop ,val)
|
((,prop ,val)
|
||||||
(-> (apply (-> (primitive 'cons))
|
(-> (apply (-> (primitive 'cons))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;;;; ecmascript.test --- ECMAScript. -*- mode: scheme; coding: utf-8; -*-
|
;;;; ecmascript.test --- ECMAScript. -*- mode: scheme; coding: utf-8; -*-
|
||||||
;;;;
|
;;;;
|
||||||
;;;; Copyright (C) 2010 Free Software Foundation, Inc.
|
;;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This library is free software; you can redistribute it and/or
|
;;;; This library is free software; you can redistribute it and/or
|
||||||
;;;; modify it under the terms of the GNU Lesser General Public
|
;;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -53,6 +53,12 @@
|
||||||
|
|
||||||
(define-syntax ecompile
|
(define-syntax ecompile
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
|
((_ expression)
|
||||||
|
(pass-if expression
|
||||||
|
(not (not
|
||||||
|
(compile (call-with-input-string expression read-ecmascript)
|
||||||
|
#:from 'ecmascript
|
||||||
|
#:to 'value)))))
|
||||||
((_ expression expected)
|
((_ expression expected)
|
||||||
(pass-if expression
|
(pass-if expression
|
||||||
(equal? expected
|
(equal? expected
|
||||||
|
@ -65,6 +71,7 @@
|
||||||
(ecompile "true;" #t)
|
(ecompile "true;" #t)
|
||||||
(ecompile "2 + 2;" 4)
|
(ecompile "2 + 2;" 4)
|
||||||
(ecompile "\"hello\";" "hello")
|
(ecompile "\"hello\";" "hello")
|
||||||
|
(ecompile "var test = { bar: 1 };")
|
||||||
|
|
||||||
;; FIXME: Broken!
|
;; FIXME: Broken!
|
||||||
;; (ecompile "[1,2,3,4].map(function(x) { return x * x; });"
|
;; (ecompile "[1,2,3,4].map(function(x) { return x * x; });"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue