Skip to content

Commit ce45896

Browse files
committed
Merge remote-tracking branch 'dop251/master' into updateGoja
2 parents 5b6154c + 0ba9a54 commit ce45896

File tree

4 files changed

+177
-61
lines changed

4 files changed

+177
-61
lines changed

.tc39_test262_checkout.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -e
22
# this is just the commit it was last tested with
3-
sha=cb4a6c8074671c00df8cbc17a620c0f9462b312a
3+
sha=3af36bec45bd4f72d4b57366653578e1e4dafef7
44

55
mkdir -p testdata/test262
66
cd testdata/test262

builtin_date.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -684,219 +684,219 @@ func _dateSetMilliseconds(year, mon, day, hours, min, sec int64, t time.Time, ca
684684
func (r *Runtime) dateproto_setMilliseconds(call FunctionCall) Value {
685685
obj := r.toObject(call.This)
686686
if d, ok := obj.self.(*dateObject); ok {
687+
tv := d.msec
687688
n := call.Argument(0).ToNumber()
689+
if tv == timeUnset {
690+
return _NaN
691+
}
688692
if IsNaN(n) {
689693
d.unset()
690694
return _NaN
691695
}
692696
msec := n.ToInteger()
693-
sec := d.msec / 1e3
697+
sec := tv / 1e3
694698
var ok bool
695699
sec, msec, ok = _norm(sec, msec, 1e3)
696700
if !ok {
697701
d.unset()
698702
return _NaN
699703
}
700-
if d.isSet() {
701-
return d.setTimeMs(sec*1e3 + msec)
702-
} else {
703-
return _NaN
704-
}
704+
return d.setTimeMs(sec*1e3 + msec)
705705
}
706706
panic(r.NewTypeError("Method Date.prototype.setMilliseconds is called on incompatible receiver"))
707707
}
708708

709709
func (r *Runtime) dateproto_setUTCMilliseconds(call FunctionCall) Value {
710710
obj := r.toObject(call.This)
711711
if d, ok := obj.self.(*dateObject); ok {
712+
tv := d.msec
712713
n := call.Argument(0).ToNumber()
714+
if tv == timeUnset {
715+
return _NaN
716+
}
713717
if IsNaN(n) {
714718
d.unset()
715719
return _NaN
716720
}
717721
msec := n.ToInteger()
718-
sec := d.msec / 1e3
722+
sec := tv / 1e3
719723
var ok bool
720724
sec, msec, ok = _norm(sec, msec, 1e3)
721725
if !ok {
722726
d.unset()
723727
return _NaN
724728
}
725-
if d.isSet() {
726-
return d.setTimeMs(sec*1e3 + msec)
727-
} else {
728-
return _NaN
729-
}
729+
return d.setTimeMs(sec*1e3 + msec)
730730
}
731731
panic(r.NewTypeError("Method Date.prototype.setUTCMilliseconds is called on incompatible receiver"))
732732
}
733733

734734
func (r *Runtime) dateproto_setSeconds(call FunctionCall) Value {
735735
obj := r.toObject(call.This)
736736
if d, ok := obj.self.(*dateObject); ok {
737+
tv := d.msec
737738
t, ok := _dateSetFullYear(d.time(), call, -5, false)
738739
if !ok {
739740
d.unset()
740741
return _NaN
741742
}
742-
if d.isSet() {
743-
return d.setTimeMs(timeToMsec(t))
744-
} else {
743+
if tv == timeUnset {
745744
return _NaN
746745
}
746+
return d.setTimeMs(timeToMsec(t))
747747
}
748748
panic(r.NewTypeError("Method Date.prototype.setSeconds is called on incompatible receiver"))
749749
}
750750

751751
func (r *Runtime) dateproto_setUTCSeconds(call FunctionCall) Value {
752752
obj := r.toObject(call.This)
753753
if d, ok := obj.self.(*dateObject); ok {
754+
tv := d.msec
754755
t, ok := _dateSetFullYear(d.timeUTC(), call, -5, true)
755756
if !ok {
756757
d.unset()
757758
return _NaN
758759
}
759-
if d.isSet() {
760-
return d.setTimeMs(timeToMsec(t))
761-
} else {
760+
if tv == timeUnset {
762761
return _NaN
763762
}
763+
return d.setTimeMs(timeToMsec(t))
764764
}
765765
panic(r.NewTypeError("Method Date.prototype.setUTCSeconds is called on incompatible receiver"))
766766
}
767767

768768
func (r *Runtime) dateproto_setMinutes(call FunctionCall) Value {
769769
obj := r.toObject(call.This)
770770
if d, ok := obj.self.(*dateObject); ok {
771+
tv := d.msec
771772
t, ok := _dateSetFullYear(d.time(), call, -4, false)
772773
if !ok {
773774
d.unset()
774775
return _NaN
775776
}
776-
if d.isSet() {
777-
return d.setTimeMs(timeToMsec(t))
778-
} else {
777+
if tv == timeUnset {
779778
return _NaN
780779
}
780+
return d.setTimeMs(timeToMsec(t))
781781
}
782782
panic(r.NewTypeError("Method Date.prototype.setMinutes is called on incompatible receiver"))
783783
}
784784

785785
func (r *Runtime) dateproto_setUTCMinutes(call FunctionCall) Value {
786786
obj := r.toObject(call.This)
787787
if d, ok := obj.self.(*dateObject); ok {
788+
tv := d.msec
788789
t, ok := _dateSetFullYear(d.timeUTC(), call, -4, true)
789790
if !ok {
790791
d.unset()
791792
return _NaN
792793
}
793-
if d.isSet() {
794-
return d.setTimeMs(timeToMsec(t))
795-
} else {
794+
if tv == timeUnset {
796795
return _NaN
797796
}
797+
return d.setTimeMs(timeToMsec(t))
798798
}
799799
panic(r.NewTypeError("Method Date.prototype.setUTCMinutes is called on incompatible receiver"))
800800
}
801801

802802
func (r *Runtime) dateproto_setHours(call FunctionCall) Value {
803803
obj := r.toObject(call.This)
804804
if d, ok := obj.self.(*dateObject); ok {
805+
tv := d.msec
805806
t, ok := _dateSetFullYear(d.time(), call, -3, false)
806807
if !ok {
807808
d.unset()
808809
return _NaN
809810
}
810-
if d.isSet() {
811-
return d.setTimeMs(timeToMsec(t))
812-
} else {
811+
if tv == timeUnset {
813812
return _NaN
814813
}
814+
return d.setTimeMs(timeToMsec(t))
815815
}
816816
panic(r.NewTypeError("Method Date.prototype.setHours is called on incompatible receiver"))
817817
}
818818

819819
func (r *Runtime) dateproto_setUTCHours(call FunctionCall) Value {
820820
obj := r.toObject(call.This)
821821
if d, ok := obj.self.(*dateObject); ok {
822+
tv := d.msec
822823
t, ok := _dateSetFullYear(d.timeUTC(), call, -3, true)
823824
if !ok {
824825
d.unset()
825826
return _NaN
826827
}
827-
if d.isSet() {
828-
return d.setTimeMs(timeToMsec(t))
829-
} else {
828+
if tv == timeUnset {
830829
return _NaN
831830
}
831+
return d.setTimeMs(timeToMsec(t))
832832
}
833833
panic(r.NewTypeError("Method Date.prototype.setUTCHours is called on incompatible receiver"))
834834
}
835835

836836
func (r *Runtime) dateproto_setDate(call FunctionCall) Value {
837837
obj := r.toObject(call.This)
838838
if d, ok := obj.self.(*dateObject); ok {
839+
tv := d.msec
839840
t, ok := _dateSetFullYear(d.time(), limitCallArgs(call, 1), -2, false)
840841
if !ok {
841842
d.unset()
842843
return _NaN
843844
}
844-
if d.isSet() {
845-
return d.setTimeMs(timeToMsec(t))
846-
} else {
845+
if tv == timeUnset {
847846
return _NaN
848847
}
848+
return d.setTimeMs(timeToMsec(t))
849849
}
850850
panic(r.NewTypeError("Method Date.prototype.setDate is called on incompatible receiver"))
851851
}
852852

853853
func (r *Runtime) dateproto_setUTCDate(call FunctionCall) Value {
854854
obj := r.toObject(call.This)
855855
if d, ok := obj.self.(*dateObject); ok {
856+
tv := d.msec
856857
t, ok := _dateSetFullYear(d.timeUTC(), limitCallArgs(call, 1), -2, true)
857858
if !ok {
858859
d.unset()
859860
return _NaN
860861
}
861-
if d.isSet() {
862-
return d.setTimeMs(timeToMsec(t))
863-
} else {
862+
if tv == timeUnset {
864863
return _NaN
865864
}
865+
return d.setTimeMs(timeToMsec(t))
866866
}
867867
panic(r.NewTypeError("Method Date.prototype.setUTCDate is called on incompatible receiver"))
868868
}
869869

870870
func (r *Runtime) dateproto_setMonth(call FunctionCall) Value {
871871
obj := r.toObject(call.This)
872872
if d, ok := obj.self.(*dateObject); ok {
873+
tv := d.msec
873874
t, ok := _dateSetFullYear(d.time(), limitCallArgs(call, 2), -1, false)
874875
if !ok {
875876
d.unset()
876877
return _NaN
877878
}
878-
if d.isSet() {
879-
return d.setTimeMs(timeToMsec(t))
880-
} else {
879+
if tv == timeUnset {
881880
return _NaN
882881
}
882+
return d.setTimeMs(timeToMsec(t))
883883
}
884884
panic(r.NewTypeError("Method Date.prototype.setMonth is called on incompatible receiver"))
885885
}
886886

887887
func (r *Runtime) dateproto_setUTCMonth(call FunctionCall) Value {
888888
obj := r.toObject(call.This)
889889
if d, ok := obj.self.(*dateObject); ok {
890+
tv := d.msec
890891
t, ok := _dateSetFullYear(d.timeUTC(), limitCallArgs(call, 2), -1, true)
891892
if !ok {
892893
d.unset()
893894
return _NaN
894895
}
895-
if d.isSet() {
896-
return d.setTimeMs(timeToMsec(t))
897-
} else {
896+
if tv == timeUnset {
898897
return _NaN
899898
}
899+
return d.setTimeMs(timeToMsec(t))
900900
}
901901
panic(r.NewTypeError("Method Date.prototype.setUTCMonth is called on incompatible receiver"))
902902
}

builtin_string.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func (r *Runtime) stringproto_localeCompare(call FunctionCall) Value {
381381
func (r *Runtime) stringproto_match(call FunctionCall) Value {
382382
r.checkObjectCoercible(call.This)
383383
regexp := call.Argument(0)
384-
if regexp != _undefined && regexp != _null {
384+
if _, ok := regexp.(*Object); ok {
385385
if matcher := toMethod(r.getV(regexp, SymMatch)); matcher != nil {
386386
return matcher(FunctionCall{
387387
This: regexp,
@@ -412,14 +412,12 @@ func (r *Runtime) stringproto_match(call FunctionCall) Value {
412412
func (r *Runtime) stringproto_matchAll(call FunctionCall) Value {
413413
r.checkObjectCoercible(call.This)
414414
regexp := call.Argument(0)
415-
if regexp != _undefined && regexp != _null {
415+
if o, ok := regexp.(*Object); ok {
416416
if isRegexp(regexp) {
417-
if o, ok := regexp.(*Object); ok {
418-
flags := nilSafe(o.self.getStr("flags", nil))
419-
r.checkObjectCoercible(flags)
420-
if !strings.Contains(flags.toString().String(), "g") {
421-
panic(r.NewTypeError("RegExp doesn't have global flag set"))
422-
}
417+
flags := nilSafe(o.self.getStr("flags", nil))
418+
r.checkObjectCoercible(flags)
419+
if !strings.Contains(flags.toString().String(), "g") {
420+
panic(r.NewTypeError("RegExp doesn't have global flag set"))
423421
}
424422
}
425423
if matcher := toMethod(r.getV(regexp, SymMatchAll)); matcher != nil {
@@ -664,7 +662,7 @@ func (r *Runtime) stringproto_replace(call FunctionCall) Value {
664662
r.checkObjectCoercible(call.This)
665663
searchValue := call.Argument(0)
666664
replaceValue := call.Argument(1)
667-
if searchValue != _undefined && searchValue != _null {
665+
if _, ok := searchValue.(*Object); ok {
668666
if replacer := toMethod(r.getV(searchValue, SymReplace)); replacer != nil {
669667
return replacer(FunctionCall{
670668
This: searchValue,
@@ -689,14 +687,12 @@ func (r *Runtime) stringproto_replaceAll(call FunctionCall) Value {
689687
r.checkObjectCoercible(call.This)
690688
searchValue := call.Argument(0)
691689
replaceValue := call.Argument(1)
692-
if searchValue != _undefined && searchValue != _null {
690+
if o, ok := searchValue.(*Object); ok {
693691
if isRegexp(searchValue) {
694-
if o, ok := searchValue.(*Object); ok {
695-
flags := nilSafe(o.self.getStr("flags", nil))
696-
r.checkObjectCoercible(flags)
697-
if !strings.Contains(flags.toString().String(), "g") {
698-
panic(r.NewTypeError("String.prototype.replaceAll called with a non-global RegExp argument"))
699-
}
692+
flags := nilSafe(o.self.getStr("flags", nil))
693+
r.checkObjectCoercible(flags)
694+
if !strings.Contains(flags.toString().String(), "g") {
695+
panic(r.NewTypeError("String.prototype.replaceAll called with a non-global RegExp argument"))
700696
}
701697
}
702698
if replacer := toMethod(r.getV(searchValue, SymReplace)); replacer != nil {
@@ -726,7 +722,7 @@ func (r *Runtime) stringproto_replaceAll(call FunctionCall) Value {
726722
func (r *Runtime) stringproto_search(call FunctionCall) Value {
727723
r.checkObjectCoercible(call.This)
728724
regexp := call.Argument(0)
729-
if regexp != _undefined && regexp != _null {
725+
if _, ok := regexp.(*Object); ok {
730726
if searcher := toMethod(r.getV(regexp, SymSearch)); searcher != nil {
731727
return searcher(FunctionCall{
732728
This: regexp,
@@ -799,7 +795,7 @@ func (r *Runtime) stringproto_split(call FunctionCall) Value {
799795
r.checkObjectCoercible(call.This)
800796
separatorValue := call.Argument(0)
801797
limitValue := call.Argument(1)
802-
if separatorValue != _undefined && separatorValue != _null {
798+
if _, ok := separatorValue.(*Object); ok {
803799
if splitter := toMethod(r.getV(separatorValue, SymSplit)); splitter != nil {
804800
return splitter(FunctionCall{
805801
This: separatorValue,

0 commit comments

Comments
 (0)