comparison libinterp/octave-value/ov-scalar.cc @ 18196:0d5721873d6b

avoid some tests that rely on ordering of enum values * ov-base-sparse.cc (octave_base_sparse<T>::map): Use explicit list of umap_X cases instead of relying on specific ordering of enum values. * ov-float.cc (octave_float_scalar::map): Likewise. * ov-flt-re-mat.cc (octave_float_matrix::map): Likewise. * ov-re-mat.cc (octave_matrix::map): Likewise. * ov-scalar.cc (octave_scalar::map): Likewise.
author John W. Eaton <jwe@octave.org>
date Thu, 02 Jan 2014 23:18:45 -0500
parents 1b6db9303933
children b7d3e1f762e1
comparison
equal deleted inserted replaced
18195:1b6db9303933 18196:0d5721873d6b
346 // Special cases for Matlab compatibility. 346 // Special cases for Matlab compatibility.
347 case umap_xtolower: 347 case umap_xtolower:
348 case umap_xtoupper: 348 case umap_xtoupper:
349 return scalar; 349 return scalar;
350 350
351 case umap_xisalnum:
352 case umap_xisalpha:
353 case umap_xisascii:
354 case umap_xiscntrl:
355 case umap_xisdigit:
356 case umap_xisgraph:
357 case umap_xislower:
358 case umap_xisprint:
359 case umap_xispunct:
360 case umap_xisspace:
361 case umap_xisupper:
362 case umap_xisxdigit:
363 case umap_xsignbit:
364 case umap_xtoascii:
365 {
366 octave_value str_conv = convert_to_str (true, true);
367 return error_state ? octave_value () : str_conv.map (umap);
368 }
369
351 default: 370 default:
352 // FIXME: this will break if some well-meaning person rearranges 371 return octave_base_value::map (umap);
353 // the enum list in ov-base.h.
354 if (umap >= umap_xisalnum && umap <= umap_xtoupper)
355 {
356 octave_value str_conv = convert_to_str (true, true);
357 return error_state ? octave_value () : str_conv.map (umap);
358 }
359 else
360 return octave_base_value::map (umap);
361 } 372 }
362 } 373 }
363 374
364 bool 375 bool
365 octave_scalar::fast_elem_insert_self (void *where, builtin_type_t btyp) const 376 octave_scalar::fast_elem_insert_self (void *where, builtin_type_t btyp) const