mirror of
https://github.com/enso-org/enso.git
synced 2024-12-22 18:38:11 +03:00
Expand and improve pretty
for core data types, vector and table. (#11438)
- ✅ Alter default `Any.pretty` so constructor is prefixed with type name (as needed now). ![image](https://github.com/user-attachments/assets/72d5ff2f-b567-47e2-becf-2e4acd4d089d) - ✅ Tests for `pretty` on `Date`. - `pretty` for ✅ `Date_Time` and ✅ `Time_Of_Day` improved to not have as much noise. - `pretty` for ✅ `Period`, ✅ `Date_Range` and ✅ `Range`. - Added custom `pretty` for ✅ `Vector` and ✅ `Array` as built-in method doesn't call through to overrides. - Added custom `pretty` for ✅ `Column` and ✅ `Table`. - Bug fix for `pretty` in `Time_Zone` so calls through to `pretty` of the zone_id to ensure safely escaped. - Initial `default_widget` for `Date` and `Time_Of_Day`. - Improve widget for `Date.to_date_time`. ![image](https://github.com/user-attachments/assets/18bc1d88-8ea9-42d0-8a9c-bc873e5d6835) - `to_text`, `to_display_text` and `pretty` for `Enso_Secret` ![image](https://github.com/user-attachments/assets/d850c109-d1af-4b6f-a450-013c4d137805) - private constructor for `Enso_Secret` as can't be correctly built directly. - Use `_` for the testing methods in `HTTP` to clarify they shouldn't be used in general code.
This commit is contained in:
parent
950a93ddeb
commit
610ee5fdec
@ -78,14 +78,23 @@ type Any
|
|||||||
to_text : Text
|
to_text : Text
|
||||||
to_text self = @Builtin_Method "Any.to_text"
|
to_text self = @Builtin_Method "Any.to_text"
|
||||||
|
|
||||||
## ICON convert
|
## GROUP convert
|
||||||
Generic conversion of an arbitrary Enso value to a corresponding human-readable
|
ICON enso_logo
|
||||||
representation.
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
|
||||||
> Example
|
> Example
|
||||||
Getting a human-readable representation of the number 7.
|
Getting the Enso code of the number 7.
|
||||||
|
|
||||||
7.to_text
|
7.pretty
|
||||||
|
## Returns a Text
|
||||||
|
7
|
||||||
|
|
||||||
|
> Example
|
||||||
|
Getting the Enso code of the text Hello World!.
|
||||||
|
|
||||||
|
"Hello World!".pretty
|
||||||
|
## Returns a Text
|
||||||
|
'Hello World!'
|
||||||
pretty : Text
|
pretty : Text
|
||||||
pretty self = @Builtin_Method "Any.pretty"
|
pretty self = @Builtin_Method "Any.pretty"
|
||||||
|
|
||||||
|
@ -795,6 +795,13 @@ type Array
|
|||||||
to_display_text : Text
|
to_display_text : Text
|
||||||
to_display_text self = self.short_display_text max_entries=40
|
to_display_text self = self.short_display_text max_entries=40
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
pretty : Text
|
||||||
|
pretty self = self.map .pretty . join ", " "[" "]"
|
||||||
|
|
||||||
## ICON column_add
|
## ICON column_add
|
||||||
Combines all the elements of a non-empty array using a binary operation.
|
Combines all the elements of a non-empty array using a binary operation.
|
||||||
If the array is empty, it returns `if_empty`.
|
If the array is empty, it returns `if_empty`.
|
||||||
|
@ -574,6 +574,23 @@ type Range
|
|||||||
step = if self.step.abs == 1 then "" else " by " + self.step.to_display_text
|
step = if self.step.abs == 1 then "" else " by " + self.step.to_display_text
|
||||||
start + step + "]"
|
start + step + "]"
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
|
||||||
|
> Example
|
||||||
|
Getting the Enso code of the range 1 until 29.
|
||||||
|
|
||||||
|
1.up_to 29 . pretty
|
||||||
|
## Returns a Text
|
||||||
|
Range.new 1 29
|
||||||
|
pretty : Text
|
||||||
|
pretty self =
|
||||||
|
start = self.start.pretty
|
||||||
|
end = self.end.pretty
|
||||||
|
"Range.new " + start + " " + end + (if self.step.abs == 1 then "" else " step=" + self.step.abs.pretty)
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
throw_zero_step_error = Error.throw (Illegal_State.Error "A range with step = 0 is ill-formed.")
|
throw_zero_step_error = Error.throw (Illegal_State.Error "A range with step = 0 is ill-formed.")
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ import project.Panic.Panic
|
|||||||
from project.Data.Boolean import Boolean, False, True
|
from project.Data.Boolean import Boolean, False, True
|
||||||
from project.Data.Text.Extensions import all
|
from project.Data.Text.Extensions import all
|
||||||
from project.Data.Time.Date_Time import ensure_in_epoch
|
from project.Data.Time.Date_Time import ensure_in_epoch
|
||||||
from project.Metadata import Display, Widget
|
from project.Metadata import Display, make_single_choice, Widget
|
||||||
|
from project.Metadata.Choice import Option
|
||||||
from project.Widget_Helpers import make_date_format_selector
|
from project.Widget_Helpers import make_date_format_selector
|
||||||
|
|
||||||
polyglot java import java.lang.ArithmeticException
|
polyglot java import java.lang.ArithmeticException
|
||||||
@ -335,7 +336,7 @@ type Date
|
|||||||
Arguments:
|
Arguments:
|
||||||
- period: the period to add to self.
|
- period: the period to add to self.
|
||||||
next : Date_Period -> Date
|
next : Date_Period -> Date
|
||||||
next self period=Date_Period.Day = self + period.to_period
|
next self period:Date_Period=..Day = self + period.to_period
|
||||||
|
|
||||||
## GROUP DateTime
|
## GROUP DateTime
|
||||||
ICON time
|
ICON time
|
||||||
@ -347,7 +348,7 @@ type Date
|
|||||||
Arguments:
|
Arguments:
|
||||||
- period: the period to add to self.
|
- period: the period to add to self.
|
||||||
previous : Date_Period -> Date
|
previous : Date_Period -> Date
|
||||||
previous self period=Date_Period.Day = self - period.to_period
|
previous self period:Date_Period=..Day = self - period.to_period
|
||||||
|
|
||||||
## GROUP DateTime
|
## GROUP DateTime
|
||||||
ICON time
|
ICON time
|
||||||
@ -492,6 +493,8 @@ type Date
|
|||||||
from Standard.Base import Date, Time_Of_Day, Time_Zone
|
from Standard.Base import Date, Time_Of_Day, Time_Zone
|
||||||
|
|
||||||
example_to_time = Date.new 2020 2 3 . to_date_time Time_Of_Day.new Time_Zone.utc
|
example_to_time = Date.new 2020 2 3 . to_date_time Time_Of_Day.new Time_Zone.utc
|
||||||
|
@time_of_day (Time_Of_Day.default_widget include_now=False)
|
||||||
|
@zone Time_Zone.default_widget
|
||||||
to_date_time : Time_Of_Day -> Time_Zone -> Date_Time
|
to_date_time : Time_Of_Day -> Time_Zone -> Date_Time
|
||||||
to_date_time self (time_of_day=Time_Of_Day.new) (zone=Time_Zone.system) =
|
to_date_time self (time_of_day=Time_Of_Day.new) (zone=Time_Zone.system) =
|
||||||
Time_Utils.make_zoned_date_time self time_of_day zone
|
Time_Utils.make_zoned_date_time self time_of_day zone
|
||||||
@ -827,9 +830,25 @@ type Date
|
|||||||
format.format_date self
|
format.format_date self
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Convert to a Enso code representation of this Date.
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
|
||||||
|
> Example
|
||||||
|
Getting the Enso code of the date 29-October-2024.
|
||||||
|
|
||||||
|
(Date.new 2024 10 29).pretty
|
||||||
|
## Returns a Text
|
||||||
|
Date.new 2024 10 29
|
||||||
pretty : Text
|
pretty : Text
|
||||||
pretty self = "(Date.new " + self.year.to_text + " " + self.month.to_text + " " + self.day.to_text + ")"
|
pretty self = "Date.new " + self.year.to_text + " " + self.month.to_text + " " + self.day.to_text
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
Gets the default drop down option for Date.
|
||||||
|
default_widget : Boolean -> Widget
|
||||||
|
default_widget (include_today:Boolean=False) =
|
||||||
|
options = [Option "<Fixed Date>" "Date.new"] + (if include_today then [Option "<Today>" "Date.today"] else [])
|
||||||
|
Widget.Single_Choice values=options display=Display.When_Modified
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
week_days_between start end =
|
week_days_between start end =
|
||||||
|
@ -101,9 +101,22 @@ type Date_Range
|
|||||||
start + step + "]"
|
start + step + "]"
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Convert to a human-readable representation.
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
|
||||||
|
> Example
|
||||||
|
Getting the Enso code of the date range 10-September-2024 until
|
||||||
|
29-October-2024.
|
||||||
|
|
||||||
|
(Date.new 2024 09 10).up_to (Date.new 2024 10 29) . pretty
|
||||||
|
## Returns a Text
|
||||||
|
Date_Range.new (Date.new 2024 09 10) (Date.new 2024 10 29)
|
||||||
pretty : Text
|
pretty : Text
|
||||||
pretty self = self.to_text
|
pretty self =
|
||||||
|
start = self.start.pretty
|
||||||
|
end = self.end.pretty
|
||||||
|
"Date_Range.new (" + start + ") (" + end + (if self.step == (Period.new days=1) then ")" else ") (" + self.step.pretty + ")")
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Converts this value to a JSON serializable object.
|
Converts this value to a JSON serializable object.
|
||||||
|
@ -836,18 +836,28 @@ type Date_Time
|
|||||||
self.format "yyyy-MM-dd "+time_format+zone_format
|
self.format "yyyy-MM-dd "+time_format+zone_format
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Convert to a Enso code representation of this Time_Of_Day.
|
GROUP convert
|
||||||
pretty : Text
|
ICON enso_logo
|
||||||
pretty self = "(Date_Time.new " + self.year.to_text + " " + self.month.to_text + " " + self.day.to_text
|
Convert the value to a corresponding Enso code representation.
|
||||||
+ (if self.hour == 0 then "" else " hour="+self.hour.to_text)
|
|
||||||
+ (if self.minute == 0 then "" else " minute="+self.minute.to_text)
|
|
||||||
+ (if self.second == 0 then "" else " second="+self.second.to_text)
|
|
||||||
+ (if self.millisecond == 0 then "" else " millisecond="+self.millisecond.to_text)
|
|
||||||
+ (if self.microsecond == 0 then "" else " microsecond="+self.microsecond.to_text)
|
|
||||||
+ (if self.nanosecond == 0 then "" else " nanosecond="+self.nanosecond.to_text)
|
|
||||||
+ (if self.zone == Time_Zone.system then "" else " zone="+self.zone.pretty)
|
|
||||||
+ ")"
|
|
||||||
|
|
||||||
|
> Example
|
||||||
|
Getting the Enso code of the date 29-October-2024 12:34.
|
||||||
|
|
||||||
|
(Date_Time.new 2024 10 29 12 34).pretty
|
||||||
|
## Returns a Text
|
||||||
|
Date_Time.new 2024 10 29 12 34
|
||||||
|
pretty : Text
|
||||||
|
pretty self =
|
||||||
|
parts = Vector.build builder->
|
||||||
|
builder.append ("Date_Time.new " + self.year.to_text + " " + self.month.to_text + " " + self.day.to_text)
|
||||||
|
if self.hour != 0 then builder.append ((if builder.length!=1 then " hour=" else " ") + self.hour.to_text)
|
||||||
|
if self.minute != 0 then builder.append ((if builder.length!=2 then " minute=" else " ") + self.minute.to_text)
|
||||||
|
if self.second != 0 then builder.append ((if builder.length!=3 then " second=" else " ") + self.second.to_text)
|
||||||
|
if self.millisecond != 0 then builder.append ((if builder.length!=4 then " millisecond=" else " ") + self.millisecond.to_text)
|
||||||
|
if self.microsecond != 0 then builder.append ((if builder.length!=5 then " microsecond=" else " ") + self.microsecond.to_text)
|
||||||
|
if self.nanosecond != 0 then builder.append ((if builder.length!=6 then " nanosecond=" else " ") + self.nanosecond.to_text)
|
||||||
|
if self.zone != Time_Zone.system then builder.append ((if builder.length!=7 then " zone=(" else " (") + self.zone.pretty + ")")
|
||||||
|
parts.join ""
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Convert to a JavaScript Object representing a Date_Time.
|
Convert to a JavaScript Object representing a Date_Time.
|
||||||
|
@ -209,6 +209,26 @@ type Period
|
|||||||
if self.days==0 . not then builder.append ["days", self.days]
|
if self.days==0 . not then builder.append ["days", self.days]
|
||||||
JS_Object.from_pairs v
|
JS_Object.from_pairs v
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
|
||||||
|
> Example
|
||||||
|
Getting the Enso code of the period 1 month and 2 days.
|
||||||
|
|
||||||
|
(Period.new months=1 days=2).pretty
|
||||||
|
## Returns a Text
|
||||||
|
Time_Of_Day.new 12 34 millisecond=500
|
||||||
|
pretty : Text
|
||||||
|
pretty self =
|
||||||
|
parts = Vector.build builder->
|
||||||
|
builder.append "Period.new"
|
||||||
|
if self.years != 0 then builder.append ((if builder.length!=1 then " years=" else " ") + self.years.to_text)
|
||||||
|
if self.months != 0 then builder.append ((if builder.length!=2 then " months=" else " ") + self.months.to_text)
|
||||||
|
if self.days != 0 then builder.append ((if builder.length!=3 then " days=" else " ") + self.days.to_text)
|
||||||
|
parts.join ""
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
catch_java_exceptions operation ~action =
|
catch_java_exceptions operation ~action =
|
||||||
handle_arithmetic_exception caught_panic =
|
handle_arithmetic_exception caught_panic =
|
||||||
|
@ -11,6 +11,7 @@ import project.Data.Time.Duration.Duration
|
|||||||
import project.Data.Time.Period.Period
|
import project.Data.Time.Period.Period
|
||||||
import project.Data.Time.Time_Period.Time_Period
|
import project.Data.Time.Time_Period.Time_Period
|
||||||
import project.Data.Time.Time_Zone.Time_Zone
|
import project.Data.Time.Time_Zone.Time_Zone
|
||||||
|
import project.Data.Vector.Vector
|
||||||
import project.Error.Error
|
import project.Error.Error
|
||||||
import project.Errors.Common.Type_Error
|
import project.Errors.Common.Type_Error
|
||||||
import project.Errors.Illegal_Argument.Illegal_Argument
|
import project.Errors.Illegal_Argument.Illegal_Argument
|
||||||
@ -20,7 +21,8 @@ import project.Nothing.Nothing
|
|||||||
import project.Panic.Panic
|
import project.Panic.Panic
|
||||||
from project.Data.Boolean import Boolean, False, True
|
from project.Data.Boolean import Boolean, False, True
|
||||||
from project.Data.Text.Extensions import all
|
from project.Data.Text.Extensions import all
|
||||||
from project.Metadata import Display, Widget
|
from project.Metadata import Display, make_single_choice, Widget
|
||||||
|
from project.Metadata.Choice import Option
|
||||||
from project.Widget_Helpers import make_time_format_selector
|
from project.Widget_Helpers import make_time_format_selector
|
||||||
|
|
||||||
polyglot java import java.lang.Exception as JException
|
polyglot java import java.lang.Exception as JException
|
||||||
@ -492,16 +494,34 @@ type Time_Of_Day
|
|||||||
format.format_time self
|
format.format_time self
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Convert to a Enso code representation of this Time_Of_Day.
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
|
||||||
|
> Example
|
||||||
|
Getting the Enso code of the time 12:34:00.5
|
||||||
|
|
||||||
|
(Time_Of_Day.new 12 34 0 500).pretty
|
||||||
|
## Returns a Text
|
||||||
|
Time_Of_Day.new 12 34 millisecond=500
|
||||||
pretty : Text
|
pretty : Text
|
||||||
pretty self = "(Time_Of_Day.new"
|
pretty self =
|
||||||
+ (if self.hour == 0 then "" else " hour="+self.hour.to_text)
|
parts = Vector.build builder->
|
||||||
+ (if self.minute == 0 then "" else " minute="+self.minute.to_text)
|
builder.append "Time_Of_Day.new"
|
||||||
+ (if self.second == 0 then "" else " second="+self.second.to_text)
|
if self.hour != 0 then builder.append ((if builder.length!=1 then " hour=" else " ") + self.hour.to_text)
|
||||||
+ (if self.millisecond == 0 then "" else " millisecond="+self.millisecond.to_text)
|
if self.minute != 0 then builder.append ((if builder.length!=2 then " minute=" else " ") + self.minute.to_text)
|
||||||
+ (if self.microsecond == 0 then "" else " microsecond="+self.microsecond.to_text)
|
if self.second != 0 then builder.append ((if builder.length!=3 then " second=" else " ") + self.second.to_text)
|
||||||
+ (if self.nanosecond == 0 then "" else " nanosecond="+self.nanosecond.to_text)
|
if self.millisecond != 0 then builder.append ((if builder.length!=4 then " millisecond=" else " ") + self.millisecond.to_text)
|
||||||
+ ")"
|
if self.microsecond != 0 then builder.append ((if builder.length!=5 then " microsecond=" else " ") + self.microsecond.to_text)
|
||||||
|
if self.nanosecond != 0 then builder.append ((if builder.length!=6 then " nanosecond=" else " ") + self.nanosecond.to_text)
|
||||||
|
parts.join ""
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
Gets the default drop down option for Time_Of_Day.
|
||||||
|
default_widget : Boolean -> Widget
|
||||||
|
default_widget (include_now:Boolean=False) =
|
||||||
|
options = [Option "<Fixed Time>" "Time_Of_Day.new"] + (if include_now then [Option "<Now>" "Time_Of_Day.now"] else [])
|
||||||
|
Widget.Single_Choice values=options display=Display.When_Modified
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Time_Of_Day.from (that:JS_Object) =
|
Time_Of_Day.from (that:JS_Object) =
|
||||||
|
@ -214,10 +214,11 @@ type Time_Zone
|
|||||||
zone_names = Time_Utils.getZoneNames
|
zone_names = Time_Utils.getZoneNames
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Convert to a Enso code representation of this Time_Of_Day.
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
pretty : Text
|
pretty : Text
|
||||||
pretty self = "(Time_Zone.parse '" + self.zone_id + "')"
|
pretty self = "Time_Zone.parse " + self.zone_id.pretty
|
||||||
|
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Time_Zone.from (that:JS_Object) =
|
Time_Zone.from (that:JS_Object) =
|
||||||
|
@ -878,6 +878,14 @@ type Vector a
|
|||||||
short_display_text self (max_entries : Integer = 10) =
|
short_display_text self (max_entries : Integer = 10) =
|
||||||
Array_Like_Helpers.short_display_text self max_entries
|
Array_Like_Helpers.short_display_text self max_entries
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
pretty : Text
|
||||||
|
pretty self = self.map .pretty . join ", " "[" "]"
|
||||||
|
|
||||||
|
|
||||||
## ALIAS append, concatenate, union
|
## ALIAS append, concatenate, union
|
||||||
GROUP Operators
|
GROUP Operators
|
||||||
ICON union
|
ICON union
|
||||||
|
@ -530,6 +530,7 @@ type Enso_File
|
|||||||
"Enso_File "+self.path
|
"Enso_File "+self.path
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
|
Converts the file descriptor to a JSON object.
|
||||||
to_js_object : JS_Object
|
to_js_object : JS_Object
|
||||||
to_js_object self =
|
to_js_object self =
|
||||||
JS_Object.from_pairs [["type", "Enso_File"], ["constructor", "new"], ["path", self.path.to_text]]
|
JS_Object.from_pairs [["type", "Enso_File"], ["constructor", "new"], ["path", self.path.to_text]]
|
||||||
|
@ -31,7 +31,19 @@ polyglot java import org.enso.base.enso_cloud.HideableValue.SecretValue
|
|||||||
## A reference to a secret stored in the Enso Cloud.
|
## A reference to a secret stored in the Enso Cloud.
|
||||||
type Enso_Secret
|
type Enso_Secret
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Value name:Text id:Text path:Enso_Path
|
private Value internal_name:Text id:Text internal_path:Enso_Path
|
||||||
|
|
||||||
|
## GROUP Metadata
|
||||||
|
ICON metadata
|
||||||
|
The name of the secret.
|
||||||
|
name : Text
|
||||||
|
name self = self.internal_name
|
||||||
|
|
||||||
|
## GROUP Metadata
|
||||||
|
ICON metadata
|
||||||
|
The path of the secret.
|
||||||
|
path : Text
|
||||||
|
path self = self.internal_path.to_text
|
||||||
|
|
||||||
## GROUP Output
|
## GROUP Output
|
||||||
ICON edit
|
ICON edit
|
||||||
@ -146,6 +158,29 @@ type Enso_Secret
|
|||||||
EnsoSecretHelper.deleteSecretFromCache self.id
|
EnsoSecretHelper.deleteSecretFromCache self.id
|
||||||
self
|
self
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
Returns a text representation of the secret.
|
||||||
|
to_text : Text
|
||||||
|
to_text self = "Enso_Secret " + self.path.to_text
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
Returns a display text representation of the secret.
|
||||||
|
to_display_text : Text
|
||||||
|
to_display_text self = "Enso_Secret {" + self.name + "}"
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
Converts the secret to a JSON object.
|
||||||
|
to_js_object : JS_Object
|
||||||
|
to_js_object self =
|
||||||
|
JS_Object.from_pairs [["type", "Enso_Secret"], ["constructor", "get"], ["path", self.path.to_text]]
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
GROUP convert
|
||||||
|
ICON enso_logo
|
||||||
|
Convert the value to a corresponding Enso code representation.
|
||||||
|
pretty : Text
|
||||||
|
pretty self = "Enso_Secret.get " + self.path.to_text.pretty
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
type Enso_Secret_Error
|
type Enso_Secret_Error
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
|
@ -355,20 +355,20 @@ type Request_Error
|
|||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Access the HTTP's timeout (for testing purposes).
|
Access the HTTP's timeout (for testing purposes).
|
||||||
get_timeout : HTTP -> Duration
|
_get_timeout : HTTP -> Duration
|
||||||
get_timeout http:HTTP = http.timeout
|
_get_timeout http:HTTP = http.timeout
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Access the HTTP's follow_redirects (for testing purposes).
|
Access the HTTP's follow_redirects (for testing purposes).
|
||||||
get_follow_redirects : HTTP -> Boolean
|
_get_follow_redirects : HTTP -> Boolean
|
||||||
get_follow_redirects http:HTTP = http.follow_redirects
|
_get_follow_redirects http:HTTP = http.follow_redirects
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Access the HTTP's proxy (for testing purposes).
|
Access the HTTP's proxy (for testing purposes).
|
||||||
get_proxy : HTTP -> Proxy
|
_get_proxy : HTTP -> Proxy
|
||||||
get_proxy http:HTTP = http.proxy
|
_get_proxy http:HTTP = http.proxy
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Access the HTTP's version (for testing purposes).
|
Access the HTTP's version (for testing purposes).
|
||||||
get_version : HTTP -> HTTP_Version
|
_get_version : HTTP -> HTTP_Version
|
||||||
get_version http:HTTP = http.version
|
_get_version http:HTTP = http.version
|
||||||
|
@ -193,7 +193,7 @@ type Response
|
|||||||
|
|
||||||
example_write =
|
example_write =
|
||||||
Data.fetch Examples.geo_data_url . write Examples.scratch_file
|
Data.fetch Examples.geo_data_url . write Examples.scratch_file
|
||||||
@path (Widget.Text_Input display=Display.Always)
|
@file (Widget.Text_Input display=Display.Always)
|
||||||
write : Writable_File -> Existing_File_Behavior -> File
|
write : Writable_File -> Existing_File_Behavior -> File
|
||||||
write self file:Writable_File on_existing_file=Existing_File_Behavior.Backup =
|
write self file:Writable_File on_existing_file=Existing_File_Behavior.Backup =
|
||||||
self.body.write file on_existing_file
|
self.body.write file on_existing_file
|
||||||
|
@ -180,7 +180,7 @@ type Response_Body
|
|||||||
|
|
||||||
example_write =
|
example_write =
|
||||||
Examples.get_geo_data.write Examples.scratch_file
|
Examples.get_geo_data.write Examples.scratch_file
|
||||||
@path (Widget.Text_Input display=Display.Always)
|
@file (Widget.Text_Input display=Display.Always)
|
||||||
write : Writable_File -> Existing_File_Behavior -> File
|
write : Writable_File -> Existing_File_Behavior -> File
|
||||||
write self file:Writable_File on_existing_file=Existing_File_Behavior.Backup =
|
write self file:Writable_File on_existing_file=Existing_File_Behavior.Backup =
|
||||||
self.with_stream body_stream->
|
self.with_stream body_stream->
|
||||||
|
@ -232,7 +232,7 @@ type Bytes
|
|||||||
type JSON_Format
|
type JSON_Format
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Resolve an unresolved constructor to the actual type.
|
Resolve an unresolved constructor to the actual type.
|
||||||
resolve : Function -> Bytes | Nothing
|
resolve : Function -> JSON_Format | Nothing
|
||||||
resolve constructor =
|
resolve constructor =
|
||||||
_ = constructor
|
_ = constructor
|
||||||
Nothing
|
Nothing
|
||||||
|
@ -2589,6 +2589,13 @@ type Column
|
|||||||
data = Statistic.running self.to_vector statistic
|
data = Statistic.running self.to_vector statistic
|
||||||
Column.from_vector name data
|
Column.from_vector name data
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
pretty : Text
|
||||||
|
pretty self =
|
||||||
|
name = self.name.pretty
|
||||||
|
data = self.to_vector.pretty
|
||||||
|
"Column.from_vector " + name + " " + data
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
|
|
||||||
Folds the vectorized operation over the provided column and values. When more
|
Folds the vectorized operation over the provided column and values. When more
|
||||||
|
@ -3739,6 +3739,12 @@ type Table
|
|||||||
if merged_columns.is_empty then problem_builder_for_unification.raise_no_output_columns_with_cause else
|
if merged_columns.is_empty then problem_builder_for_unification.raise_no_output_columns_with_cause else
|
||||||
Table.new merged_columns
|
Table.new merged_columns
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
pretty : Text
|
||||||
|
pretty self =
|
||||||
|
data = self.columns.map c->("[" + c.name.pretty + ", " + c.to_vector.pretty + "]") . join ", "
|
||||||
|
"Table.new [" + data + "]"
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
A helper to create a new table consisting of slices of the original table.
|
A helper to create a new table consisting of slices of the original table.
|
||||||
slice_ranges table ranges =
|
slice_ranges table ranges =
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
from Standard.Base import all
|
from Standard.Base import all
|
||||||
|
import Standard.Base.Metadata.Widget
|
||||||
import Standard.Base.Errors.Common.Not_Invokable
|
import Standard.Base.Errors.Common.Not_Invokable
|
||||||
|
from Standard.Base.Logging import all
|
||||||
from Standard.Base.Meta import Instrumentor
|
from Standard.Base.Meta import Instrumentor
|
||||||
|
|
||||||
from Standard.Table import all
|
from Standard.Table import all
|
||||||
@ -20,7 +22,11 @@ get_widget_json value call_name argument_names uuids="{}" =
|
|||||||
uuid:Text -> Instrumentor.uuid uuid
|
uuid:Text -> Instrumentor.uuid uuid
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
read_annotation argument =
|
log_panic argument err =
|
||||||
|
Widget.log_message "Failed for "+argument+": "+err.payload.to_display_text ..Warning
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
read_annotation argument = Panic.catch Any handler=(log_panic argument) <|
|
||||||
annotation = Warning.clear <| Meta.get_annotation value call_name argument
|
annotation = Warning.clear <| Meta.get_annotation value call_name argument
|
||||||
return_target err = err.payload.target
|
return_target err = err.payload.target
|
||||||
Panic.catch Not_Invokable handler=return_target
|
Panic.catch Not_Invokable handler=return_target
|
||||||
|
@ -47,7 +47,7 @@ public abstract class AnyPrettyNode extends Node {
|
|||||||
|
|
||||||
@CompilerDirectives.TruffleBoundary
|
@CompilerDirectives.TruffleBoundary
|
||||||
private Text consName(AtomConstructor constructor) {
|
private Text consName(AtomConstructor constructor) {
|
||||||
return Text.create(constructor.getDisplayName());
|
return Text.create(constructor.getType().getName() + "." + constructor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@CompilerDirectives.TruffleBoundary
|
@CompilerDirectives.TruffleBoundary
|
||||||
|
@ -49,6 +49,14 @@ add_specs suite_builder =
|
|||||||
make_enso_array [] . reduce (+) . should_fail_with (Empty_Error.Error Array)
|
make_enso_array [] . reduce (+) . should_fail_with (Empty_Error.Error Array)
|
||||||
make_enso_array [] . reduce (+) 0 . should_equal 0
|
make_enso_array [] . reduce (+) 0 . should_equal 0
|
||||||
|
|
||||||
|
group_builder.specify "should have a well-defined debug-printing method" <|
|
||||||
|
## Enso arrays should be coded as Vectors when Enso code is generated.
|
||||||
|
make_enso_array [] . pretty . should_equal "[]"
|
||||||
|
make_enso_array [1,2,3] . pretty . should_equal "[1, 2, 3]"
|
||||||
|
make_enso_array [Nothing] . pretty . should_equal "[Nothing]"
|
||||||
|
make_enso_array [True, False, 'a'] . pretty . should_equal "[True, False, 'a']"
|
||||||
|
make_enso_array [Date.new 2022 1 1] . pretty . should_equal "[Date.new 2022 1 1]"
|
||||||
|
|
||||||
suite_builder.group "Compare functionality with Vector" group_builder->
|
suite_builder.group "Compare functionality with Vector" group_builder->
|
||||||
group_builder.specify "compare methods" <|
|
group_builder.specify "compare methods" <|
|
||||||
vector_methods = Meta.meta Vector . methods . sort
|
vector_methods = Meta.meta Vector . methods . sort
|
||||||
|
@ -7,6 +7,7 @@ import Standard.Base.Errors.Common.Type_Error
|
|||||||
import Standard.Base.Errors.Common.Unsupported_Argument_Types
|
import Standard.Base.Errors.Common.Unsupported_Argument_Types
|
||||||
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
||||||
import Standard.Base.Errors.Illegal_State.Illegal_State
|
import Standard.Base.Errors.Illegal_State.Illegal_State
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
from Standard.Test import all
|
from Standard.Test import all
|
||||||
|
|
||||||
@ -559,6 +560,24 @@ add_specs suite_builder = suite_builder.group "Range" group_builder->
|
|||||||
invalid_range . find _->True . should_fail_with Illegal_State
|
invalid_range . find _->True . should_fail_with Illegal_State
|
||||||
invalid_range . contains 0 . should_fail_with Illegal_State
|
invalid_range . contains 0 . should_fail_with Illegal_State
|
||||||
|
|
||||||
|
group_builder.specify "should define friendly text representations" <|
|
||||||
|
range = 1.up_to 100
|
||||||
|
range_2 = 0.up_to 10 . with_step 2
|
||||||
|
range_3 = 20.down_to 0 . with_step 3
|
||||||
|
|
||||||
|
range.to_text . should_equal "(Between 1 100 1)"
|
||||||
|
range_2.to_text . should_equal "(Between 0 10 2)"
|
||||||
|
range_3.to_text . should_equal "(Between 20 0 -3)"
|
||||||
|
|
||||||
|
range.to_display_text . should_equal "[1 .. 100]"
|
||||||
|
range_2.to_display_text . should_equal "[0 .. 10 by 2]"
|
||||||
|
range_3.to_display_text . should_equal "[20 .. 0 by -3]"
|
||||||
|
|
||||||
|
range.pretty . should_equal "Range.new 1 100"
|
||||||
|
range_2.pretty . should_equal "Range.new 0 10 step=2"
|
||||||
|
range_3.pretty . should_equal "Range.new 20 0 step=3"
|
||||||
|
Debug.eval range_3.pretty . should_equal range_3
|
||||||
|
|
||||||
main filter=Nothing =
|
main filter=Nothing =
|
||||||
suite = Test.build suite_builder->
|
suite = Test.build suite_builder->
|
||||||
add_specs suite_builder
|
add_specs suite_builder
|
||||||
|
@ -2,6 +2,7 @@ from Standard.Base import all
|
|||||||
import Standard.Base.Errors.Common.Type_Error
|
import Standard.Base.Errors.Common.Type_Error
|
||||||
import Standard.Base.Errors.Empty_Error.Empty_Error
|
import Standard.Base.Errors.Empty_Error.Empty_Error
|
||||||
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
from Standard.Test import all
|
from Standard.Test import all
|
||||||
|
|
||||||
@ -194,8 +195,11 @@ add_specs suite_builder =
|
|||||||
r1.to_text . should_equal '(Date_Range from 2020-02-28 up to 2020-03-02)'
|
r1.to_text . should_equal '(Date_Range from 2020-02-28 up to 2020-03-02)'
|
||||||
r2.to_text . should_equal '(Date_Range from 2020-03-20 down to 2020-02-29 by 7D)'
|
r2.to_text . should_equal '(Date_Range from 2020-03-20 down to 2020-02-29 by 7D)'
|
||||||
|
|
||||||
r1.pretty . should_equal r1.to_text
|
r1.pretty . should_equal 'Date_Range.new (Date.new 2020 2 28) (Date.new 2020 3 2)'
|
||||||
r2.pretty . should_equal r2.to_text
|
(Debug.eval r1.pretty) . should_equal r1
|
||||||
|
|
||||||
|
r2.pretty . should_equal 'Date_Range.new (Date.new 2020 3 20) (Date.new 2020 2 29) (Period.new days=7)'
|
||||||
|
(Debug.eval r2.pretty) . should_equal r2
|
||||||
|
|
||||||
r1.to_display_text . should_equal '[2020-02-28 .. 2020-03-02]'
|
r1.to_display_text . should_equal '[2020-02-28 .. 2020-03-02]'
|
||||||
r2.to_display_text . should_equal '[2020-03-20 .. 2020-02-29 by -7D]'
|
r2.to_display_text . should_equal '[2020-03-20 .. 2020-02-29 by -7D]'
|
||||||
|
@ -2,6 +2,7 @@ from Standard.Base import all
|
|||||||
import Standard.Base.Errors.Common.Incomparable_Values
|
import Standard.Base.Errors.Common.Incomparable_Values
|
||||||
import Standard.Base.Errors.Common.Type_Error
|
import Standard.Base.Errors.Common.Type_Error
|
||||||
import Standard.Base.Errors.Time_Error.Time_Error
|
import Standard.Base.Errors.Time_Error.Time_Error
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
from Standard.Test import all
|
from Standard.Test import all
|
||||||
|
|
||||||
@ -96,6 +97,11 @@ spec_with suite_builder name create_new_date parse_date pending=Nothing =
|
|||||||
datetime.date . should_equal date
|
datetime.date . should_equal date
|
||||||
datetime.time_of_day . should_equal time
|
datetime.time_of_day . should_equal time
|
||||||
|
|
||||||
|
group_builder.specify "should convert to Enso code" <|
|
||||||
|
date = create_new_date 2001 12 21
|
||||||
|
date.pretty . should_equal "Date.new 2001 12 21"
|
||||||
|
Debug.eval date.pretty . should_equal date
|
||||||
|
|
||||||
group_builder.specify "should convert to Json" <|
|
group_builder.specify "should convert to Json" <|
|
||||||
date = create_new_date 2001 12 21
|
date = create_new_date 2001 12 21
|
||||||
date.to_json.should_equal <|
|
date.to_json.should_equal <|
|
||||||
|
@ -2,6 +2,7 @@ from Standard.Base import all
|
|||||||
import Standard.Base.Errors.Common.Incomparable_Values
|
import Standard.Base.Errors.Common.Incomparable_Values
|
||||||
import Standard.Base.Errors.Common.Type_Error
|
import Standard.Base.Errors.Common.Type_Error
|
||||||
import Standard.Base.Errors.Time_Error.Time_Error
|
import Standard.Base.Errors.Time_Error.Time_Error
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
from Standard.Test import all
|
from Standard.Test import all
|
||||||
|
|
||||||
@ -119,6 +120,18 @@ spec_with suite_builder name create_new_datetime parse_datetime nanoseconds_loss
|
|||||||
text = create_new_datetime 1970 (zone = Time_Zone.utc) . to_text
|
text = create_new_datetime 1970 (zone = Time_Zone.utc) . to_text
|
||||||
text . should_equal "1970-01-01 00:00:00Z[UTC]"
|
text . should_equal "1970-01-01 00:00:00Z[UTC]"
|
||||||
|
|
||||||
|
group_builder.specify "should convert to Enso code" <|
|
||||||
|
create_new_datetime 1970 . pretty . should_equal "Date_Time.new 1970 1 1"
|
||||||
|
create_new_datetime 1923 9 24 . pretty . should_equal "Date_Time.new 1923 9 24"
|
||||||
|
create_new_datetime 1923 9 24 12 20 44 . pretty . should_equal "Date_Time.new 1923 9 24 12 20 44"
|
||||||
|
if nanoseconds_loss_in_precision.not then
|
||||||
|
create_new_datetime 1923 9 24 12 20 nanosecond=500000000 . pretty . should_equal "Date_Time.new 1923 9 24 12 20 millisecond=500"
|
||||||
|
create_new_datetime 1923 9 24 12 20 nanosecond=500000 . pretty . should_equal "Date_Time.new 1923 9 24 12 20 microsecond=500"
|
||||||
|
create_new_datetime 1923 9 24 12 20 nanosecond=500 . pretty . should_equal "Date_Time.new 1923 9 24 12 20 nanosecond=500"
|
||||||
|
|
||||||
|
date_time = create_new_datetime 1970 12 21 11 23 45 nanosecond=123456789 zone=Time_Zone.utc
|
||||||
|
Debug.eval date_time.pretty . should_equal date_time
|
||||||
|
|
||||||
group_builder.specify "should convert to Json" <|
|
group_builder.specify "should convert to Json" <|
|
||||||
time = create_new_datetime 1970 12 21 (zone = Time_Zone.utc)
|
time = create_new_datetime 1970 12 21 (zone = Time_Zone.utc)
|
||||||
time.to_json.should_equal <|
|
time.to_json.should_equal <|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from Standard.Base import all
|
from Standard.Base import all
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
from Standard.Test import all
|
from Standard.Test import all
|
||||||
|
|
||||||
@ -11,6 +12,10 @@ add_specs suite_builder =
|
|||||||
Day_Of_Week.Friday.to_integer . should_equal 6
|
Day_Of_Week.Friday.to_integer . should_equal 6
|
||||||
Day_Of_Week.Saturday.to_integer . should_equal 7
|
Day_Of_Week.Saturday.to_integer . should_equal 7
|
||||||
|
|
||||||
|
group_builder.specify "should be able to convert to Enso code" <|
|
||||||
|
Day_Of_Week.Sunday.pretty . should_equal "Day_Of_Week.Sunday"
|
||||||
|
Debug.eval Day_Of_Week.Wednesday.pretty . should_equal Day_Of_Week.Wednesday
|
||||||
|
|
||||||
group_builder.specify "should be able to convert from an Integer" <|
|
group_builder.specify "should be able to convert from an Integer" <|
|
||||||
Day_Of_Week.from 1 . should_equal Day_Of_Week.Sunday
|
Day_Of_Week.from 1 . should_equal Day_Of_Week.Sunday
|
||||||
Day_Of_Week.from 4 . should_equal Day_Of_Week.Wednesday
|
Day_Of_Week.from 4 . should_equal Day_Of_Week.Wednesday
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from Standard.Base import all
|
from Standard.Base import all
|
||||||
import Standard.Base.Errors.Common.Incomparable_Values
|
import Standard.Base.Errors.Common.Incomparable_Values
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
from Standard.Test import all
|
from Standard.Test import all
|
||||||
|
|
||||||
@ -50,6 +51,18 @@ add_specs suite_builder =
|
|||||||
Period.new years=2 days=3 . to_display_text . should_equal "2Y 0M 3D"
|
Period.new years=2 days=3 . to_display_text . should_equal "2Y 0M 3D"
|
||||||
Period.new days=18 . to_display_text . should_equal "18D"
|
Period.new days=18 . to_display_text . should_equal "18D"
|
||||||
|
|
||||||
|
group_builder.specify "should render to Enso code" <|
|
||||||
|
Period.new . pretty . should_equal "Period.new"
|
||||||
|
Period.new years=2 . pretty . should_equal "Period.new 2"
|
||||||
|
Period.new months=24 . pretty . should_equal "Period.new months=24"
|
||||||
|
Period.new months=4 . pretty . should_equal "Period.new months=4"
|
||||||
|
Period.new years=1 months=6 . pretty . should_equal "Period.new 1 6"
|
||||||
|
Period.new years=2 days=3 . pretty . should_equal "Period.new 2 days=3"
|
||||||
|
Period.new days=18 . pretty . should_equal "Period.new days=18"
|
||||||
|
|
||||||
|
period = Period.new years=2 days=3
|
||||||
|
Debug.eval period.pretty . should_equal period
|
||||||
|
|
||||||
main filter=Nothing =
|
main filter=Nothing =
|
||||||
suite = Test.build suite_builder->
|
suite = Test.build suite_builder->
|
||||||
add_specs suite_builder
|
add_specs suite_builder
|
||||||
|
@ -3,6 +3,7 @@ import Standard.Base.Errors.Common.Incomparable_Values
|
|||||||
import Standard.Base.Errors.Common.Type_Error
|
import Standard.Base.Errors.Common.Type_Error
|
||||||
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
||||||
import Standard.Base.Errors.Time_Error.Time_Error
|
import Standard.Base.Errors.Time_Error.Time_Error
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
from Standard.Test import all
|
from Standard.Test import all
|
||||||
|
|
||||||
@ -58,6 +59,16 @@ specWith suite_builder name create_new_time parse_time nanoseconds_loss_in_preci
|
|||||||
text = create_new_time 12 20 44 . to_text
|
text = create_new_time 12 20 44 . to_text
|
||||||
text . should_equal "12:20:44"
|
text . should_equal "12:20:44"
|
||||||
|
|
||||||
|
group_builder.specify "should convert to Enso code" <|
|
||||||
|
create_new_time 12 20 . pretty . should_equal "Time_Of_Day.new 12 20"
|
||||||
|
create_new_time 12 20 44 . pretty . should_equal "Time_Of_Day.new 12 20 44"
|
||||||
|
create_new_time 12 20 0 500000000 . pretty . should_equal "Time_Of_Day.new 12 20 millisecond=500"
|
||||||
|
create_new_time 12 20 0 500000 . pretty . should_equal "Time_Of_Day.new 12 20 microsecond=500"
|
||||||
|
if nanoseconds_loss_in_precision.not then create_new_time 12 20 0 500 . pretty . should_equal "Time_Of_Day.new 12 20 nanosecond=500"
|
||||||
|
|
||||||
|
time = create_new_time 12 20 0 500000
|
||||||
|
Debug.eval time.pretty . should_equal time
|
||||||
|
|
||||||
group_builder.specify "should convert to Json" <|
|
group_builder.specify "should convert to Json" <|
|
||||||
time = create_new_time 1 2 3
|
time = create_new_time 1 2 3
|
||||||
time.to_json.should_equal <|
|
time.to_json.should_equal <|
|
||||||
|
@ -12,6 +12,7 @@ import Standard.Base.Errors.Common.Not_Found
|
|||||||
import Standard.Base.Errors.Common.Type_Error
|
import Standard.Base.Errors.Common.Type_Error
|
||||||
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
||||||
import Standard.Base.Errors.Unimplemented.Unimplemented
|
import Standard.Base.Errors.Unimplemented.Unimplemented
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
import Standard.Base.Runtime.Ref.Ref
|
import Standard.Base.Runtime.Ref.Ref
|
||||||
import Standard.Base.Runtime.State
|
import Standard.Base.Runtime.State
|
||||||
from Standard.Base.Panic import Wrapped_Dataflow_Error
|
from Standard.Base.Panic import Wrapped_Dataflow_Error
|
||||||
@ -1243,6 +1244,11 @@ add_specs suite_builder =
|
|||||||
[Nothing].pretty.should_equal "[Nothing]"
|
[Nothing].pretty.should_equal "[Nothing]"
|
||||||
[True, False, 'a'].pretty . should_equal "[True, False, 'a']"
|
[True, False, 'a'].pretty . should_equal "[True, False, 'a']"
|
||||||
[Foo.Value True].pretty . should_equal "[(Foo.Value True)]"
|
[Foo.Value True].pretty . should_equal "[(Foo.Value True)]"
|
||||||
|
[Date.new 2022 1 1].pretty . should_equal "[Date.new 2022 1 1]"
|
||||||
|
|
||||||
|
mixed = [1, 2, 'a', (Foo.Value True), Date.new 2022 1 1, Nothing]
|
||||||
|
mixed.pretty . should_equal "[1, 2, 'a', (Foo.Value True), Date.new 2022 1 1, Nothing]"
|
||||||
|
Debug.eval (mixed.pretty) . should_equal [1, 2, 'a', Foo.Value True, Date.new 2022 1 1, Nothing]
|
||||||
|
|
||||||
type_spec suite_builder "Use Vector as vectors" identity
|
type_spec suite_builder "Use Vector as vectors" identity
|
||||||
type_spec suite_builder "Use Array as vectors" (v -> v.to_array)
|
type_spec suite_builder "Use Array as vectors" (v -> v.to_array)
|
||||||
|
@ -11,7 +11,7 @@ import Standard.Base.Network.HTTP.Request_Body.Request_Body
|
|||||||
import Standard.Base.Network.HTTP.Request_Error
|
import Standard.Base.Network.HTTP.Request_Error
|
||||||
import Standard.Base.Network.Proxy.Proxy
|
import Standard.Base.Network.Proxy.Proxy
|
||||||
import Standard.Base.Runtime.Context
|
import Standard.Base.Runtime.Context
|
||||||
from Standard.Base.Network.HTTP import _resolve_headers, get_follow_redirects, get_proxy, get_timeout, get_version
|
from Standard.Base.Network.HTTP import _resolve_headers, _get_follow_redirects, _get_proxy, _get_timeout, _get_version
|
||||||
|
|
||||||
from Standard.Test import all
|
from Standard.Test import all
|
||||||
from Standard.Test.Execution_Context_Helpers import run_with_and_without_output
|
from Standard.Test.Execution_Context_Helpers import run_with_and_without_output
|
||||||
@ -66,11 +66,11 @@ add_specs suite_builder =
|
|||||||
suite_builder.group "HTTP client" pending=pending_has_url group_builder->
|
suite_builder.group "HTTP client" pending=pending_has_url group_builder->
|
||||||
group_builder.specify "should create HTTP client with timeout setting" <|
|
group_builder.specify "should create HTTP client with timeout setting" <|
|
||||||
http = HTTP.new (timeout = (Duration.new seconds=30))
|
http = HTTP.new (timeout = (Duration.new seconds=30))
|
||||||
(get_timeout http).should_equal (Duration.new seconds=30)
|
(_get_timeout http).should_equal (Duration.new seconds=30)
|
||||||
|
|
||||||
group_builder.specify "should create HTTP client with follow_redirects setting" <|
|
group_builder.specify "should create HTTP client with follow_redirects setting" <|
|
||||||
http = HTTP.new (follow_redirects = False)
|
http = HTTP.new (follow_redirects = False)
|
||||||
(get_follow_redirects http).should_equal False
|
(_get_follow_redirects http).should_equal False
|
||||||
|
|
||||||
Test.with_retries <|
|
Test.with_retries <|
|
||||||
r = http.request (Request.new HTTP_Method.Get base_url_with_slash+"test_redirect")
|
r = http.request (Request.new HTTP_Method.Get base_url_with_slash+"test_redirect")
|
||||||
@ -81,12 +81,12 @@ add_specs suite_builder =
|
|||||||
group_builder.specify "should create HTTP client with proxy setting" <|
|
group_builder.specify "should create HTTP client with proxy setting" <|
|
||||||
proxy_setting = Proxy.Address "example.com" 80
|
proxy_setting = Proxy.Address "example.com" 80
|
||||||
http = HTTP.new (proxy = proxy_setting)
|
http = HTTP.new (proxy = proxy_setting)
|
||||||
(get_proxy http).should_equal proxy_setting
|
(_get_proxy http).should_equal proxy_setting
|
||||||
|
|
||||||
group_builder.specify "should create HTTP client with version setting" <|
|
group_builder.specify "should create HTTP client with version setting" <|
|
||||||
version_setting = HTTP_Version.HTTP_2
|
version_setting = HTTP_Version.HTTP_2
|
||||||
http = HTTP.new (version = version_setting)
|
http = HTTP.new (version = version_setting)
|
||||||
(get_version http).should_equal version_setting
|
(_get_version http).should_equal version_setting
|
||||||
|
|
||||||
url_get = base_url_with_slash.if_not_nothing <| base_url_with_slash + "get"
|
url_get = base_url_with_slash.if_not_nothing <| base_url_with_slash + "get"
|
||||||
suite_builder.group "fetch" pending=pending_has_url group_builder->
|
suite_builder.group "fetch" pending=pending_has_url group_builder->
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from Standard.Base import all
|
from Standard.Base import all
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
import project.Util
|
import project.Util
|
||||||
|
|
||||||
@ -257,6 +258,20 @@ add_specs suite_builder =
|
|||||||
r2 = Column.from_vector "X" [] (Value_Type.Char size=0 variable_length=True)
|
r2 = Column.from_vector "X" [] (Value_Type.Char size=0 variable_length=True)
|
||||||
r2.should_fail_with Illegal_Argument
|
r2.should_fail_with Illegal_Argument
|
||||||
|
|
||||||
|
group_builder.specify "should be able to serialize to Enso code" <|
|
||||||
|
c1 = Column.from_vector "X" [1, 2] Value_Type.Float
|
||||||
|
c1.pretty . should_equal 'Column.from_vector \'X\' [1.0, 2.0]'
|
||||||
|
Debug.eval c1.pretty . should_equal c1
|
||||||
|
|
||||||
|
c2 = Column.from_vector "X" ["a", 42]
|
||||||
|
c2.pretty . should_equal 'Column.from_vector \'X\' [\'a\', 42]'
|
||||||
|
|
||||||
|
c3 = Column.from_vector "X" ["aaa", "bbb"]
|
||||||
|
c3.pretty . should_equal 'Column.from_vector \'X\' [\'aaa\', \'bbb\']'
|
||||||
|
|
||||||
|
c4 = Column.from_vector "X" [Time_Of_Day.new 10 11 12, Time_Of_Day.new 11 30]
|
||||||
|
c4.pretty . should_equal 'Column.from_vector \'X\' [Time_Of_Day.new 10 11 12, Time_Of_Day.new 11 30]'
|
||||||
|
|
||||||
suite_builder.group "Rounding" group_builder->
|
suite_builder.group "Rounding" group_builder->
|
||||||
group_builder.specify "should be able to round a column of decimals" <|
|
group_builder.specify "should be able to round a column of decimals" <|
|
||||||
Column.from_vector "foo" [1.2, 2.3, 2.5, 3.6] . round . should_equal (Column.from_vector "round([foo])" [1, 2, 3, 4])
|
Column.from_vector "foo" [1.2, 2.3, 2.5, 3.6] . round . should_equal (Column.from_vector "round([foo])" [1, 2, 3, 4])
|
||||||
|
@ -4,6 +4,7 @@ import Standard.Base.Errors.Common.Incomparable_Values
|
|||||||
import Standard.Base.Errors.Common.Index_Out_Of_Bounds
|
import Standard.Base.Errors.Common.Index_Out_Of_Bounds
|
||||||
import Standard.Base.Errors.Common.Type_Error
|
import Standard.Base.Errors.Common.Type_Error
|
||||||
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
||||||
|
import Standard.Base.Runtime.Debug
|
||||||
|
|
||||||
from Standard.Table import Table, Column, Sort_Column, Aggregate_Column, Blank_Selector, Value_Type
|
from Standard.Table import Table, Column, Sort_Column, Aggregate_Column, Blank_Selector, Value_Type
|
||||||
from Standard.Table.Errors import Invalid_Column_Names, Duplicate_Output_Column_Names, No_Input_Columns_Selected, Missing_Input_Columns, No_Such_Column, Floating_Point_Equality, Invalid_Value_Type, Row_Count_Mismatch
|
from Standard.Table.Errors import Invalid_Column_Names, Duplicate_Output_Column_Names, No_Input_Columns_Selected, Missing_Input_Columns, No_Such_Column, Floating_Point_Equality, Invalid_Value_Type, Row_Count_Mismatch
|
||||||
@ -88,6 +89,23 @@ add_specs suite_builder =
|
|||||||
r2.at "foo" . to_vector . should_equal []
|
r2.at "foo" . to_vector . should_equal []
|
||||||
r2.at "bar" . to_vector . should_equal []
|
r2.at "bar" . to_vector . should_equal []
|
||||||
|
|
||||||
|
group_builder.specify "should allow creating Enso code from a Table" <|
|
||||||
|
r = Table.new [["foo", [1, 2, 3]], ["bar", [False, True, False]]]
|
||||||
|
r.pretty . should_equal "Table.new [['foo', [1, 2, 3]], ['bar', [False, True, False]]]"
|
||||||
|
Debug.eval r.pretty . should_equal r
|
||||||
|
|
||||||
|
r2 = Table.new [["foo", []], ["bar", []]]
|
||||||
|
r2.pretty . should_equal "Table.new [['foo', []], ['bar', []]]"
|
||||||
|
Debug.eval r2.pretty . should_equal r2
|
||||||
|
|
||||||
|
r3 = Table.new [["date", [Date.new 2022 8 27, Date.new 1999 1 1]], ["time", [Time_Of_Day.new 18, Time_Of_Day.new 1 2 34]]]
|
||||||
|
r3.pretty . should_equal "Table.new [['date', [Date.new 2022 8 27, Date.new 1999 1 1]], ['time', [Time_Of_Day.new 18, Time_Of_Day.new 1 2 34]]]"
|
||||||
|
Debug.eval r3.pretty . should_equal r3
|
||||||
|
|
||||||
|
r4 = Table.new [["foo", [1, 2, 3]], ["bar", [False, True, False]], ["date", [Date.new 2022 8 27, Date.new 1999 1 1, Date.new 2012 1 23]], ["time", [Time_Of_Day.new 18, Time_Of_Day.new 1 2 34, Time_Of_Day.new 12 0]]]
|
||||||
|
r4.pretty . should_equal "Table.new [['foo', [1, 2, 3]], ['bar', [False, True, False]], ['date', [Date.new 2022 8 27, Date.new 1999 1 1, Date.new 2012 1 23]], ['time', [Time_Of_Day.new 18, Time_Of_Day.new 1 2 34, Time_Of_Day.new 12]]]"
|
||||||
|
Debug.eval r4.pretty . should_equal r4
|
||||||
|
|
||||||
group_builder.specify "should handle error scenarios gracefully" <|
|
group_builder.specify "should handle error scenarios gracefully" <|
|
||||||
Table.new [["X", [1,2,3]], ["Y", [4]]] . should_fail_with Illegal_Argument
|
Table.new [["X", [1,2,3]], ["Y", [4]]] . should_fail_with Illegal_Argument
|
||||||
Table.new [["X", [1]], ["X", [2]]] . should_fail_with Illegal_Argument
|
Table.new [["X", [1]], ["X", [2]]] . should_fail_with Illegal_Argument
|
||||||
|
Loading…
Reference in New Issue
Block a user