summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go')
-rw-r--r--src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go
new file mode 100644
index 00000000000..fe7c064f8c2
--- /dev/null
+++ b/src/mongo/gotools/src/github.com/mongodb/mongo-tools/vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go
@@ -0,0 +1,19 @@
+package main
+
+import (
+ "time"
+
+ "github.com/gopherjs/gopherjs/js"
+)
+
+var _ = time.Sleep // Force "time" package to be imported but let time.Time and time.Unix be DCEed since they're not used.
+
+func main() {
+ // Excercise externalization of Go struct (with its special handling of time.Time).
+ js.Global.Get("console").Call("log", struct{ S string }{"externalization ok"})
+
+ // Excercise internalization of JavaScript Date object (with its special handling of time.Time).
+ date := js.Global.Get("Date").New("2015-08-29T20:56:00.869Z").Interface()
+ js.Global.Set("myDate", date)
+ js.Global.Get("console").Call("log", js.Global.Get("myDate").Call("toUTCString"))
+}