1 |
## oils_failures_allowed: 1
|
2 |
|
3 |
|
4 |
const a = #'a'
|
5 |
const A = #'A'
|
6 |
echo "$a $A"
|
7 |
## STDOUT:
|
8 |
97 65
|
9 |
## END
|
10 |
|
11 |
|
12 |
|
13 |
# This looks too much like triple quoted strings!
|
14 |
|
15 |
echo nope
|
16 |
const bad = #'''
|
17 |
echo "$bad"
|
18 |
|
19 |
## status: 2
|
20 |
## STDOUT:
|
21 |
nope
|
22 |
## END
|
23 |
|
24 |
|
25 |
|
26 |
shopt -s ysh:upgrade
|
27 |
# 1+2 2.3
|
28 |
var x = 1.2 + 23.0e-1 # 3.5
|
29 |
if (3.4 < x and x < 3.6) {
|
30 |
echo ok
|
31 |
}
|
32 |
## STDOUT:
|
33 |
ok
|
34 |
## END
|
35 |
|
36 |
|
37 |
|
38 |
shopt -s ysh:upgrade
|
39 |
|
40 |
# 1+2 + 2.3
|
41 |
# add this _ here
|
42 |
var x = 1.2 + 2_3.0e-1 # 3.5
|
43 |
if (3.4 < x and x < 3.6) {
|
44 |
echo ok
|
45 |
}
|
46 |
|
47 |
## STDOUT:
|
48 |
ok
|
49 |
## END
|
50 |
|
51 |
|
52 |
|
53 |
echo $[0.5]
|
54 |
echo $[5.0]
|
55 |
echo $[5.]
|
56 |
echo $[.5]
|
57 |
|
58 |
## status: 2
|
59 |
## STDOUT:
|
60 |
0.5
|
61 |
5.0
|
62 |
## END
|
63 |
|
64 |
|
65 |
|
66 |
# C++ issue: we currently print with snprintf %g
|
67 |
# Pars
|
68 |
|
69 |
echo $[42_000.000_500]
|
70 |
|
71 |
echo $[42_000.000_500e1]
|
72 |
echo $[42_000.000_500e-1]
|
73 |
|
74 |
## STDOUT:
|
75 |
42000.0005
|
76 |
420000.005
|
77 |
4200.00005
|
78 |
## END
|
79 |
|
80 |
|
81 |
|
82 |
# Notes
|
83 |
# - Python float() and JS parseFloat() agree with this behavior
|
84 |
# - JSON doesn't have inf / -inf
|
85 |
|
86 |
echo $[1e309]
|
87 |
echo $[-1e309]
|
88 |
|
89 |
## STDOUT:
|
90 |
inf
|
91 |
-inf
|
92 |
## END
|
93 |
|
94 |
|
95 |
|
96 |
shopt -s ysh:upgrade
|
97 |
# TODO: need equivalent of in YSh
|
98 |
# '0' * 309
|
99 |
# ['0'] * 309
|
100 |
|
101 |
# 1e-324 == 0.0 in Python
|
102 |
|
103 |
var zeros = []
|
104 |
for i in (1 .. 324) {
|
105 |
call zeros->append('0')
|
106 |
}
|
107 |
|
108 |
#= zeros
|
109 |
|
110 |
var s = "0.$[join(zeros)]1"
|
111 |
#echo $s
|
112 |
|
113 |
echo float=$[float(s)]
|
114 |
|
115 |
## STDOUT:
|
116 |
float=0.0
|
117 |
## END
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
echo TODO
|
123 |
|
124 |
## STDOUT:
|
125 |
## END
|